summaryrefslogtreecommitdiffstats
path: root/nova/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'nova/test.py')
-rw-r--r--nova/test.py35
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)