From 76460b63f9c310c7de4e5f0c11d1525bedd277e1 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 14 Mar 2018 10:41:46 -0600 Subject: tests: Centralize and re-use skipTest based on json schema presense. This just centralizes a hunk of duplicated code and uses it from the new location. --- cloudinit/tests/helpers.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'cloudinit/tests/helpers.py') diff --git a/cloudinit/tests/helpers.py b/cloudinit/tests/helpers.py index 41d9a8ee..14c0b0bf 100644 --- a/cloudinit/tests/helpers.py +++ b/cloudinit/tests/helpers.py @@ -409,6 +409,19 @@ except AttributeError: return decorator +try: + import jsonschema + assert jsonschema # avoid pyflakes error F401: import unused + _missing_jsonschema_dep = False +except ImportError: + _missing_jsonschema_dep = True + + +def skipUnlessJsonSchema(): + return skipIf( + _missing_jsonschema_dep, "No python-jsonschema dependency present.") + + # older versions of mock do not have the useful 'assert_not_called' if not hasattr(mock.Mock, 'assert_not_called'): def __mock_assert_not_called(mmock): -- cgit v1.2.3