summaryrefslogtreecommitdiff
path: root/tests/unittests/helpers.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2014-02-13 21:18:17 -0500
committerScott Moser <smoser@ubuntu.com>2014-02-13 21:18:17 -0500
commit4ba72556193219f90c313f62d0d309761bb53c6b (patch)
tree2ad80e184d53a85a1fe5933ad106249bc522da35 /tests/unittests/helpers.py
parent507aeed12312af7fc8a9fcfca6b845183a5a3c51 (diff)
parent053667688d7c2ad51e569c62e00dac1942e46f62 (diff)
downloadvyos-cloud-init-4ba72556193219f90c313f62d0d309761bb53c6b.tar.gz
vyos-cloud-init-4ba72556193219f90c313f62d0d309761bb53c6b.zip
merge from trunk
Diffstat (limited to 'tests/unittests/helpers.py')
-rw-r--r--tests/unittests/helpers.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py
index 5b4f4208..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):
@@ -29,6 +46,12 @@ if (_PY_MAJOR, _PY_MINOR) <= (2, 6):
standardMsg = standardMsg % (member, container)
self.fail(self._formatMessage(msg, standardMsg))
+ def assertIsNone(self, value, msg=None):
+ if value is not None:
+ standardMsg = '%r is not None'
+ standardMsg = standardMsg % (value)
+ self.fail(self._formatMessage(msg, standardMsg))
+
else:
class TestCase(unittest.TestCase):
pass