Artom Lifshitz 69492a6b67 Use config fixture to avoid racing on self.flags()
Previously self.flags() set options on the global CONF singleton. This
created races where a test running in parallel would end up with
a flag value intended for another test. By using the fixture we scope
self.flags() to each individual test.

Change-Id: Id317e4b86cf7e66172040c23dc3ccf96e820204a
2019-02-08 11:10:18 -05:00

33 lines
1.1 KiB
Python

# Copyright 2018 Red Hat
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import fixture as config_fixture
from oslotest import base
from tempest import config
CONF = config.CONF
class WhiteboxPluginTestCase(base.BaseTestCase):
def setUp(self):
super(WhiteboxPluginTestCase, self).setUp()
self.useFixture(config_fixture.Config(CONF))
def flags(self, **kw):
"""Override flag variables for a test."""
group = kw.pop('group', None)
for k, v in kw.items():
CONF.set_override(k, v, group)