keystone.openstack.common.fixture package

Submodules

keystone.openstack.common.fixture.config module

class keystone.openstack.common.fixture.config.Config(conf=<oslo.config.cfg.ConfigOpts object at 0x7f7a1ab39bd0>)[source]

Bases: fixtures.fixture.Fixture

Allows overriding configuration settings for the test.

conf will be reset on cleanup.

config(**kw)[source]

Override configuration values.

The keyword arguments are the names of configuration options to override and their values.

If a group argument is supplied, the overrides are applied to the specified configuration option group, otherwise the overrides are applied to the default group.

register_opt(opt, group=None)[source]

Register a single option for the test run.

Options registered in this manner will automatically be unregistered during cleanup.

If a group argument is supplied, it will register the new option to that group, otherwise the option is registered to the default group.

register_opts(opts, group=None)[source]

Register multiple options for the test run.

This works in the same manner as register_opt() but takes a list of options as the first argument. All arguments will be registered to the same group if the group argument is supplied, otherwise all options will be registered to the default group.

setUp()[source]

keystone.openstack.common.fixture.lockutils module

class keystone.openstack.common.fixture.lockutils.LockFixture(name, lock_file_prefix=None)[source]

Bases: fixtures.fixture.Fixture

External locking fixture.

This fixture is basically an alternative to the synchronized decorator with the external flag so that tearDowns and addCleanups will be included in the lock context for locking between tests. The fixture is recommended to be the first line in a test method, like so:

def test_method(self):
    self.useFixture(LockFixture)
        ...

or the first line in setUp if all the test methods in the class are required to be serialized. Something like:

class TestCase(testtools.testcase):
    def setUp(self):
        self.useFixture(LockFixture)
        super(TestCase, self).setUp()
            ...

This is because addCleanups are put on a LIFO queue that gets run after the test method exits. (either by completing or raising an exception)

setUp()[source]

keystone.openstack.common.fixture.mockpatch module

class keystone.openstack.common.fixture.mockpatch.Patch(obj, new=sentinel.DEFAULT, **kwargs)[source]

Bases: fixtures.fixture.Fixture

Deal with code around mock.patch.

setUp()[source]
class keystone.openstack.common.fixture.mockpatch.PatchObject(obj, attr, new=sentinel.DEFAULT, **kwargs)[source]

Bases: fixtures.fixture.Fixture

Deal with code around mock.

setUp()[source]

keystone.openstack.common.fixture.moxstubout module

class keystone.openstack.common.fixture.moxstubout.MoxStubout[source]

Bases: fixtures.fixture.Fixture

Deal with code around mox and stubout as a fixture.

setUp()[source]

Module contents