diff options
author | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2016-06-09 09:40:32 +0200 |
---|---|---|
committer | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2016-06-09 09:40:32 +0200 |
commit | ab5fcc807f48eefa032c8a07ff79e9e5bd6b93a6 (patch) | |
tree | 0bd5285c6e67505e32ee1cf05a029114710b5958 /tests/unittests/helpers.py | |
parent | e6cfca0c898f0482f37216cf58e61ff1581aaaf6 (diff) | |
download | vyos-cloud-init-ab5fcc807f48eefa032c8a07ff79e9e5bd6b93a6.tar.gz vyos-cloud-init-ab5fcc807f48eefa032c8a07ff79e9e5bd6b93a6.zip |
move SkipTest definition to tests/unittests/helpers.py to be reusable
Diffstat (limited to 'tests/unittests/helpers.py')
-rw-r--r-- | tests/unittests/helpers.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py index 50b2bd72..59361215 100644 --- a/tests/unittests/helpers.py +++ b/tests/unittests/helpers.py @@ -344,3 +344,20 @@ except AttributeError: print(reason, file=sys.stderr) return wrapper return decorator + +# on SkipTest: +# - unittest SkipTest is first preference, but it's only available +# for >= 2.7 +# - unittest2 SkipTest is second preference for older pythons. This +# mirrors logic for choosing SkipTest exception in testtools +# - if none of the above, provide custom class +try: + from unittest.case import SkipTest +except ImportError: + try: + from unittest2.case import SkipTest + except ImportError: + class SkipTest(Exception): + """Raise this exception to mark a test as skipped. + """ + pass |