diff --git a/oslo_policy/opts.py b/oslo_policy/opts.py index 9bd84108..368797fc 100644 --- a/oslo_policy/opts.py +++ b/oslo_policy/opts.py @@ -120,4 +120,4 @@ def set_defaults(conf, policy_file=None): _register(conf) if policy_file is not None: - conf.set_default('policy_file', policy_file, group=_option_group) + cfg.set_defaults(_options, policy_file=policy_file) diff --git a/oslo_policy/tests/test_opts.py b/oslo_policy/tests/test_opts.py index 2ec5b346..7c455ca8 100644 --- a/oslo_policy/tests/test_opts.py +++ b/oslo_policy/tests/test_opts.py @@ -10,7 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import fixture as config +import copy + +from oslo_config import cfg from oslotest import base as test_base from oslo_policy import opts @@ -20,7 +22,13 @@ class OptsTestCase(test_base.BaseTestCase): def setUp(self): super(OptsTestCase, self).setUp() - self.conf = self.useFixture(config.Config()).conf + self.conf = cfg.ConfigOpts() + self.original_opts = opts._options + opts._options = copy.deepcopy(opts._options) + + def reset(): + opts._options = self.original_opts + self.addCleanup(reset) def test_set_defaults_policy_file(self): opts._register(self.conf)