Fix unit tests to work with stevedore > 2.0.1

stevedore has switched to importlib_metadata[1] and
this breaked unit test as the test relied on internal
implementation of it.

Instead we should switch to mock NamedExtensionManager
that's what called by oslo_config.

[1] https://review.opendev.org/#/c/739306/

Closes-Bug: #1888208
Change-Id: Ic4b990a387d875a351c9f8e7eaaef726734ff305
This commit is contained in:
yatinkarel 2020-07-23 11:05:05 +05:30
parent 392922aa33
commit a2652b3584
1 changed files with 2 additions and 2 deletions

View File

@ -1652,8 +1652,8 @@ class GeneratorRaiseErrorTestCase(base.BaseTestCase):
self.conf = cfg.ConfigOpts() self.conf = cfg.ConfigOpts()
self.conf.register_opts(generator._generator_opts) self.conf.register_opts(generator._generator_opts)
self.conf.set_default('namespace', [fake_ep.name]) self.conf.set_default('namespace', [fake_ep.name])
fake_eps = mock.Mock(return_value=[fake_ep]) with mock.patch('stevedore.named.NamedExtensionManager',
with mock.patch('pkg_resources.iter_entry_points', fake_eps): side_effect=FakeException()):
self.assertRaises(FakeException, generator.generate, self.conf) self.assertRaises(FakeException, generator.generate, self.conf)
def test_generator_call_with_no_arguments_raises_system_exit(self): def test_generator_call_with_no_arguments_raises_system_exit(self):