From 6296fce9f8e3205506f87dd31d0b18f4b7842000 Mon Sep 17 00:00:00 2001 From: yatinkarel Date: Tue, 21 Jul 2020 09:55:42 +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_policy. [1] https://review.opendev.org/#/c/739306/ Closes-Bug: #1888208 Change-Id: I993d743c53fa3506ceda3d1f291c12f4635eb60a --- oslo_policy/tests/test_generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oslo_policy/tests/test_generator.py b/oslo_policy/tests/test_generator.py index af6398fa..1f74aa33 100644 --- a/oslo_policy/tests/test_generator.py +++ b/oslo_policy/tests/test_generator.py @@ -492,8 +492,8 @@ class GeneratorRaiseErrorTestCase(testtools.TestCase): raise FakeException() fake_ep = FakeEP() - 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_sample, fake_ep.name)