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
This commit is contained in:
yatinkarel 2020-07-21 09:55:42 +05:30
parent cab28649c6
commit 6296fce9f8
1 changed files with 2 additions and 2 deletions

View File

@ -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)