Skip to content

Commit 3b4378c

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Fix mocking SafeConnectedTestCase"
2 parents 8fe9281 + 6069592 commit 3b4378c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

nova/tests/unit/scheduler/client/test_report.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,14 @@ def setUp(self):
4242
super(SafeConnectedTestCase, self).setUp()
4343
self.context = context.get_admin_context()
4444

45-
with mock.patch('keystoneauth1.loading.load_auth_from_conf_options'):
46-
self.client = report.SchedulerReportClient()
45+
# need to mock this globally as SchedulerReportClient._create_client
46+
# is called again when EndpointNotFound is raised
47+
self.useFixture(
48+
fixtures.MonkeyPatch(
49+
'keystoneauth1.loading.load_auth_from_conf_options',
50+
mock.MagicMock()))
51+
52+
self.client = report.SchedulerReportClient()
4753

4854
@mock.patch('keystoneauth1.session.Session.request')
4955
def test_missing_endpoint(self, req):

0 commit comments

Comments
 (0)