Previous topic

The nova.service Module

Next topic

The nova.utils Module

This Page

Psst... hey. You're reading the latest content, but it might be out of sync with code. You can read Nova 2011.2 docs or all OpenStack docs too.

The nova.test Module

Base classes for our unit tests.

Allows overriding of flags for use of fakes, and some black magic for inline callbacks.

class TestCase(methodName='runTest')

Bases: unittest.case.TestCase

Test case base class for all unit tests.

assertDictListMatch(L1, L2, approx_equal=False, tolerance=0.001)

Assert a list of dicts are equivalent.

assertDictMatch(d1, d2, approx_equal=False, tolerance=0.001)

Assert two dicts are equivalent.

This is a ‘deep’ match in the sense that it handles nested dictionaries appropriately.

NOTE:

If you don’t care (or don’t know) a given value, you can specify the string DONTCARE as the value. This will cause that dict-item to be skipped.
assertIn(a, b, *args, **kwargs)

Python < v2.7 compatibility. Assert ‘a’ in ‘b’

assertIsInstance(a, b, *args, **kwargs)

Python < v2.7 compatibility. Assert ‘a’ is Instance of ‘b’

assertNotIn(a, b, *args, **kwargs)

Python < v2.7 compatibility. Assert ‘a’ NOT in ‘b’

assertNotRaises(exc_class, func, *args, **kwargs)

Assert that a particular exception is not raised.

If exc_class is None, then we assert that no error is raised.

Otherwise, we assert that only a particular error wasn’t raised; if any different exceptions were raised, we just silently capture them and return.

assertSubDictMatch(sub_dict, super_dict)

Assert a sub_dict is subset of super_dict.

flags(**kw)

Override flag variables for a test.

setUp()

Run before each test method to initialize test environment.

start_service(name, host=None, **kwargs)
tearDown()

Runs after each test method to tear down test environment.

exception TestingException

Bases: exceptions.Exception

class skip_if(condition, msg)

Bases: object

Decorator that skips a test if condition is true.

skip_if_fake(func)

Decorator that skips a test if running in fake mode.

class skip_test(msg)

Bases: object

Decorator that skips a test.

class skip_unless(condition, msg)

Bases: object

Decorator that skips a test if condition is not true.