summaryrefslogtreecommitdiff
path: root/cloudinit/tests
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2018-03-14 10:41:46 -0600
committerChad Smith <chad.smith@canonical.com>2018-03-14 10:41:46 -0600
commit76460b63f9c310c7de4e5f0c11d1525bedd277e1 (patch)
treeed5ec6c4a5500e1800e093f8c66029b489e76908 /cloudinit/tests
parentf891df345afa57c0c7734e8f04cca9a3d5881778 (diff)
downloadvyos-cloud-init-76460b63f9c310c7de4e5f0c11d1525bedd277e1.tar.gz
vyos-cloud-init-76460b63f9c310c7de4e5f0c11d1525bedd277e1.zip
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.
Diffstat (limited to 'cloudinit/tests')
-rw-r--r--cloudinit/tests/helpers.py13
1 files changed, 13 insertions, 0 deletions
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):