From a2652b3584da06e4c4ebe96261672309b01c1122 Mon Sep 17 00:00:00 2001 From: yatinkarel Date: Thu, 23 Jul 2020 11:05:05 +0530 Subject: [PATCH] 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 --- oslo_config/tests/test_generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oslo_config/tests/test_generator.py b/oslo_config/tests/test_generator.py index 7cb354e9..a069e242 100644 --- a/oslo_config/tests/test_generator.py +++ b/oslo_config/tests/test_generator.py @@ -1652,8 +1652,8 @@ class GeneratorRaiseErrorTestCase(base.BaseTestCase): self.conf = cfg.ConfigOpts() self.conf.register_opts(generator._generator_opts) self.conf.set_default('namespace', [fake_ep.name]) - fake_eps = mock.Mock(return_value=[fake_ep]) - with mock.patch('pkg_resources.iter_entry_points', fake_eps): + with mock.patch('stevedore.named.NamedExtensionManager', + side_effect=FakeException()): self.assertRaises(FakeException, generator.generate, self.conf) def test_generator_call_with_no_arguments_raises_system_exit(self):