Python fixtures 模块,Fixture() 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用fixtures.Fixture()

项目:osc-lib    作者:openstack    | 项目源码 | 文件源码
def setUp(self):
        super(TestClientManager, self).setUp()
        self.mock = mock.Mock()
        self.requests = self.useFixture(fixture.Fixture())
        # fake v2password token retrieval
        self.stub_auth(json=fakes.TEST_RESPONSE_DICT)
        # fake token and token_endpoint retrieval
        self.stub_auth(json=fakes.TEST_RESPONSE_DICT,
                       url='/'.join([fakes.AUTH_URL, 'v2.0/tokens']))
        # fake v3password token retrieval
        self.stub_auth(json=fakes.TEST_RESPONSE_DICT_V3,
                       url='/'.join([fakes.AUTH_URL, 'v3/auth/tokens']))
        # fake password token retrieval
        self.stub_auth(json=fakes.TEST_RESPONSE_DICT_V3,
                       url='/'.join([fakes.AUTH_URL, 'auth/tokens']))
        # fake password version endpoint discovery
        self.stub_auth(json=fakes.TEST_VERSIONS,
                       url=fakes.AUTH_URL,
                       verb='GET')

        # Mock the auth plugin
        self.auth_mock = mock.Mock()
项目:mixmatch    作者:openstack    | 项目源码 | 文件源码
def setUp(self):
        super(BaseTest, self).setUp()
        self.requests_fixture = self.useFixture(requests_fixture.Fixture())
        self.config_fixture = self.useFixture(config_fixture.Config(conf=CONF))
        self.session_fixture = self.useFixture(SessionFixture())
        self.db_fixture = self.useFixture(DatabaseFixture(conf=CONF))
        self.app = app.test_client()

        self.service_providers = {
            'default': {
                'image_endpoint': 'http://images.local',
                'volume_endpoint': 'http://volumes.local'
            },
            'remote1': {
                'image_endpoint': 'http://images.remote1',
                'volume_endpoint': 'http://volumes.remote1'
            },
        }

        # set config values
        self.config_fixture.load_raw_values(
            service_providers='default, remote1',
            aggregation=True)
        self.config_fixture.load_raw_values(
            group='sp_default',
            image_endpoint='http://images.local',
            volume_endpoint='http://volumes.local')
        self.config_fixture.load_raw_values(
            group='sp_remote1',
            image_endpoint='http://images.remote1',
            volume_endpoint='http://volumes.remote1')
        config.post_config()
        extend.load_extensions()