diff options
author | Chris Behrens <cbehrens@codestud.com> | 2011-08-28 23:39:43 -0700 |
---|---|---|
committer | Chris Behrens <cbehrens@codestud.com> | 2011-08-28 23:39:43 -0700 |
commit | 599467124e812eb8ae73eb7a9af3fea71ee25157 (patch) | |
tree | 345e7bba8907bcdbc6dd16edd1a169999956fdd9 /nova/test.py | |
parent | 0ef2581749f39fa4fd41c2376186418e730f0afb (diff) | |
download | nova-599467124e812eb8ae73eb7a9af3fea71ee25157.tar.gz nova-599467124e812eb8ae73eb7a9af3fea71ee25157.tar.xz nova-599467124e812eb8ae73eb7a9af3fea71ee25157.zip |
fix for assertIn and assertNotIn use which was added in python 2.7. this makes things work on 2.6 still
Diffstat (limited to 'nova/test.py')
-rw-r--r-- | nova/test.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/nova/test.py b/nova/test.py index 88f1489e8..d1c1ad20e 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): + """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) |