diff options
author | William Wolf <throughnothing@gmail.com> | 2011-07-26 10:33:05 +0000 |
---|---|---|
committer | Tarmac <> | 2011-07-26 10:33:05 +0000 |
commit | cb631be09c36d29ddb6e89a647c5161bc43c4aa7 (patch) | |
tree | 5be2f5dfaeaee8dbc268f3c2f8cb26d56bd4b78d /nova/test.py | |
parent | 85522bba82a4139a89915bba99865a50fd9b8f58 (diff) | |
parent | 5df221e970d8b060423034fa627735c5c24fce5d (diff) | |
download | nova-cb631be09c36d29ddb6e89a647c5161bc43c4aa7.tar.gz nova-cb631be09c36d29ddb6e89a647c5161bc43c4aa7.tar.xz nova-cb631be09c36d29ddb6e89a647c5161bc43c4aa7.zip |
Merge diablo-3 development from trunk (rev1322)
Diffstat (limited to 'nova/test.py')
-rw-r--r-- | nova/test.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/nova/test.py b/nova/test.py index ab1eaf5fd..9790b0aa1 100644 --- a/nova/test.py +++ b/nova/test.py @@ -30,11 +30,15 @@ import uuid import unittest import mox +import nose.plugins.skip +import nova.image.fake +import shutil import stubout from eventlet import greenthread from nova import fakerabbit from nova import flags +from nova import log from nova import rpc from nova import utils from nova import service @@ -47,6 +51,22 @@ flags.DEFINE_string('sqlite_clean_db', 'clean.sqlite', flags.DEFINE_bool('fake_tests', True, 'should we use everything for testing') +LOG = log.getLogger('nova.tests') + + +class skip_test(object): + """Decorator that skips a test.""" + def __init__(self, msg): + self.message = msg + + def __call__(self, func): + def _skipper(*args, **kw): + """Wrapped skipper function.""" + raise nose.SkipTest(self.message) + _skipper.__name__ = func.__name__ + _skipper.__doc__ = func.__doc__ + return _skipper + def skip_if_fake(func): """Decorator that skips a test if running in fake mode.""" @@ -100,6 +120,9 @@ class TestCase(unittest.TestCase): if hasattr(fake.FakeConnection, '_instance'): del fake.FakeConnection._instance + if FLAGS.image_service == 'nova.image.fake.FakeImageService': + nova.image.fake.FakeImageService_reset() + # Reset any overriden flags self.reset_flags() @@ -229,3 +252,15 @@ class TestCase(unittest.TestCase): for d1, d2 in zip(L1, L2): self.assertDictMatch(d1, d2, approx_equal=approx_equal, tolerance=tolerance) + + def assertSubDictMatch(self, sub_dict, super_dict): + """Assert a sub_dict is subset of super_dict.""" + self.assertTrue(set(sub_dict.keys()).issubset(set(super_dict.keys()))) + for k, sub_value in sub_dict.items(): + super_value = super_dict[k] + if isinstance(sub_value, dict): + self.assertSubDictMatch(sub_value, super_value) + elif 'DONTCARE' in (sub_value, super_value): + continue + else: + self.assertEqual(sub_value, super_value) |