fix for assertIn and assertNotIn use which was added in python 2.7. this makes things work on 2.6 still
This commit is contained in:
18
nova/test.py
18
nova/test.py
@@ -277,3 +277,21 @@ class TestCase(unittest.TestCase):
|
||||
continue
|
||||
else:
|
||||
self.assertEqual(sub_value, super_value)
|
||||
|
||||
def assertIn(self, a, b):
|
||||
"""Python < v2.7 compatibility. Assert 'a' in 'b'"""
|
||||
try:
|
||||
f = super(TestCase, self).assertIn
|
||||
except AttributeError:
|
||||
self.assertTrue(a in b)
|
||||
else:
|
||||
f(a, b)
|
||||
|
||||
def assertNotIn(self, a, b):
|
||||
"""Python < v2.7 compatibility. Assert 'a' NOT in 'b'"""
|
||||
try:
|
||||
f = super(TestCase, self).assertNotIn
|
||||
except AttributeError:
|
||||
self.assertFalse(a in b)
|
||||
else:
|
||||
f(a, b)
|
||||
|
||||
Reference in New Issue
Block a user