37
35
import nova.image.fake
38
36
from nova import log as logging
39
37
from nova.openstack.common import cfg
38
from nova.openstack.common import timeutils
40
39
from nova import service
41
40
from nova import tests
42
41
from nova.tests import fake_flags
43
from nova import utils
44
42
from nova.virt import fake
133
131
# NOTE(vish): We need a better method for creating fixtures for tests
134
132
# now that we have some required db setup for the system
135
133
# to work properly.
136
self.start = utils.utcnow()
134
self.start = timeutils.utcnow()
139
137
# emulate some of the mox stuff, we can't use the metaclass
152
150
self.mox.VerifyAll()
153
151
super(TestCase, self).tearDown()
155
if FLAGS.connection_type == 'fake':
156
if hasattr(fake.FakeConnection, '_instance'):
157
del fake.FakeConnection._instance
159
153
if FLAGS.image_service == 'nova.image.fake.FakeImageService':
160
154
nova.image.fake.FakeImageService_reset()
295
289
self.assertFalse(a in b, *args, **kwargs)
297
291
f(a, b, *args, **kwargs)
293
def assertNotRaises(self, exc_class, func, *args, **kwargs):
294
"""Assert that a particular exception is not raised.
296
If exc_class is None, then we assert that *no* error is raised.
298
Otherwise, we assert that only a particular error wasn't raised;
299
if any different exceptions were raised, we just silently capture
302
exc_msg = kwargs.pop('exc_msg', '')
304
if exc_class is None:
305
# Ensure no errors were raised
307
return func(*args, **kwargs)
310
raise AssertionError(exc_msg)
312
# Ensure a specific error wasn't raised
314
return func(*args, **kwargs)
316
raise AssertionError(exc_msg)
318
pass # Any other errors are fine
320
def assertIsInstance(self, a, b, *args, **kwargs):
321
"""Python < v2.7 compatibility. Assert 'a' is Instance of 'b'"""
323
f = super(TestCase, self).assertIsInstance
324
except AttributeError:
325
self.assertTrue(isinstance(a, b), *args, **kwargs)
327
f(a, b, *args, **kwargs)