diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2014-02-07 16:40:51 -0800 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2014-02-07 16:40:51 -0800 |
commit | 6e40098626531397a339d3a231d821b738e69175 (patch) | |
tree | 7014442deda29683e20cea1f724c59cf5069dce4 /tests/unittests/helpers.py | |
parent | f9582464b157ffb0087b18910af11aa6ed49abcd (diff) | |
download | vyos-cloud-init-6e40098626531397a339d3a231d821b738e69175.tar.gz vyos-cloud-init-6e40098626531397a339d3a231d821b738e69175.zip |
Adjust detection of python versions and variables exposed
Diffstat (limited to 'tests/unittests/helpers.py')
-rw-r--r-- | tests/unittests/helpers.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py index 945c1500..5bed13cc 100644 --- a/tests/unittests/helpers.py +++ b/tests/unittests/helpers.py @@ -12,10 +12,27 @@ from cloudinit import util import shutil -# Handle how 2.6 doesn't have the assertIn or assertNotIn +# Used for detecting different python versions +PY2 = False +PY26 = False +PY27 = False +PY3 = False + _PY_VER = sys.version_info _PY_MAJOR, _PY_MINOR = _PY_VER[0:2] if (_PY_MAJOR, _PY_MINOR) <= (2, 6): + if (_PY_MAJOR, _PY_MINOR) == (2, 6): + PY26 = True + if (_PY_MAJOR, _PY_MINOR) >= (2, 0): + PY2 = True +else: + if (_PY_MAJOR, _PY_MINOR) == (2, 7): + PY27 = True + PY2 = True + if (_PY_MAJOR, _PY_MINOR) >= (3, 0): + PY3 = True + +if PY26: # For now add these on, taken from python 2.7 + slightly adjusted class TestCase(unittest.TestCase): def assertIn(self, member, container, msg=None): |