Skip to content

Commit 2ee9ad2

Browse files
committed
Fix mock for 'autospec' and 'new' together
mock does not accept 'autospec' and 'new' attributes together to create mock object for tests. If autospec is True the mock object is created using create_autospec() and pass the keyword args to called function. If both are passed then it start failing with oslotest 4.4.0 which is migrated to unittest.mock. - https://d088a63e8edc60022939-485bd9eedc766dc9e54cbbb4001038bd.ssl.cf5.rackcdn.com/739330/1/check/cross-nova-py36/843ec44/testr_results.html Creating mock with autospec only to fix this test to make nova pass for oslo 4.4.0 so that requirement can constraint oslotest to 4.4.0 (needed-by patch). Change-Id: I9d6d97563114380f9a7549f08cede4b808352a3e Needed-By: https://review.opendev.org/#/c/739531/
1 parent 43802e5 commit 2ee9ad2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

nova/tests/unit/scheduler/test_filter_scheduler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ class FilterSchedulerTestCase(test.NoDBTestCase):
5959
@mock.patch.object(host_manager.HostManager, '_init_aggregates',
6060
new=mock.Mock())
6161
@mock.patch('nova.scheduler.client.report.SchedulerReportClient',
62-
autospec=True, new=mock.Mock())
62+
autospec=True)
6363
@mock.patch('nova.scheduler.client.query.SchedulerQueryClient',
64-
autospec=True, new=mock.Mock())
65-
def setUp(self):
64+
autospec=True)
65+
def setUp(self, mock_sch_query, mock_sch_report):
6666
super(FilterSchedulerTestCase, self).setUp()
6767

6868
self.driver = filter_scheduler.FilterScheduler()

0 commit comments

Comments
 (0)