summaryrefslogtreecommitdiff
path: root/tests/unittests/helpers.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2014-07-16 12:57:24 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2014-07-16 12:57:24 -0700
commit81525fd93541b41d31b6da13df61a0494cc1e7f6 (patch)
treeeb182b6bc0e29b41c3953ee84092e45e51b911e7 /tests/unittests/helpers.py
parente11e7c2d1e908d99179f0382da4ac0b4d49bd7aa (diff)
downloadvyos-cloud-init-81525fd93541b41d31b6da13df61a0494cc1e7f6.tar.gz
vyos-cloud-init-81525fd93541b41d31b6da13df61a0494cc1e7f6.zip
Fix a few tests that have been failing in python 2.6
A few of the current tests have been continually failing in python 2.6 based systems, due to lack of unit test functions that are now added to ensure we can run the unit tests (and not have to ignore those failures) on python 2.6
Diffstat (limited to 'tests/unittests/helpers.py')
-rw-r--r--tests/unittests/helpers.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py
index 5bed13cc..970eb8cb 100644
--- a/tests/unittests/helpers.py
+++ b/tests/unittests/helpers.py
@@ -52,6 +52,30 @@ if PY26:
standardMsg = standardMsg % (value)
self.fail(self._formatMessage(msg, standardMsg))
+ def assertDictContainsSubset(self, expected, actual, msg=None):
+ missing = []
+ mismatched = []
+ for k, v in expected.iteritems():
+ if k not in actual:
+ missing.append(k)
+ elif actual[k] != v:
+ mismatched.append('%r, expected: %r, actual: %r'
+ % (k, v, actual[k]))
+
+ if len(missing) == 0 and len(mismatched) == 0:
+ return
+
+ standardMsg = ''
+ if missing:
+ standardMsg = 'Missing: %r' % ','.join(m for m in missing)
+ if mismatched:
+ if standardMsg:
+ standardMsg += '; '
+ standardMsg += 'Mismatched values: %s' % ','.join(mismatched)
+
+ self.fail(self._formatMessage(msg, standardMsg))
+
+
else:
class TestCase(unittest.TestCase):
pass