summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/test.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/nova/test.py b/nova/test.py
index 88f1489e8..d759aef60 100644
--- a/nova/test.py
+++ b/nova/test.py
@@ -277,3 +277,21 @@ class TestCase(unittest.TestCase):
continue
else:
self.assertEqual(sub_value, super_value)
+
+ def assertIn(self, a, b, *args, **kwargs):
+ """Python < v2.7 compatibility. Assert 'a' in 'b'"""
+ try:
+ f = super(TestCase, self).assertIn
+ except AttributeError:
+ self.assertTrue(a in b, *args, **kwargs)
+ else:
+ f(a, b, *args, **kwargs)
+
+ def assertNotIn(self, a, b, *args, **kwargs):
+ """Python < v2.7 compatibility. Assert 'a' NOT in 'b'"""
+ try:
+ f = super(TestCase, self).assertNotIn
+ except AttributeError:
+ self.assertFalse(a in b, *args, **kwargs)
+ else:
+ f(a, b, *args, **kwargs)