From 2ee9ad25167629f58fb374d8266a27996eadc174 Mon Sep 17 00:00:00 2001 From: Ghanshyam Mann Date: Sat, 4 Jul 2020 18:55:07 -0500 Subject: [PATCH] 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/ --- nova/tests/unit/scheduler/test_filter_scheduler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/tests/unit/scheduler/test_filter_scheduler.py b/nova/tests/unit/scheduler/test_filter_scheduler.py index 7a5e6c232f9c..18809b6d7b8a 100644 --- a/nova/tests/unit/scheduler/test_filter_scheduler.py +++ b/nova/tests/unit/scheduler/test_filter_scheduler.py @@ -59,10 +59,10 @@ class FilterSchedulerTestCase(test.NoDBTestCase): @mock.patch.object(host_manager.HostManager, '_init_aggregates', new=mock.Mock()) @mock.patch('nova.scheduler.client.report.SchedulerReportClient', - autospec=True, new=mock.Mock()) + autospec=True) @mock.patch('nova.scheduler.client.query.SchedulerQueryClient', - autospec=True, new=mock.Mock()) - def setUp(self): + autospec=True) + def setUp(self, mock_sch_query, mock_sch_report): super(FilterSchedulerTestCase, self).setUp() self.driver = filter_scheduler.FilterScheduler()