diff --git a/ironic_lib/tests/test_disk_utils.py b/ironic_lib/tests/test_disk_utils.py index 85e53335..d7b7a4a3 100644 --- a/ironic_lib/tests/test_disk_utils.py +++ b/ironic_lib/tests/test_disk_utils.py @@ -1058,7 +1058,7 @@ class WholeDiskConfigDriveTestCases(test_base.BaseTestCase): @mock.patch.object(disk_utils, 'count_mbr_partitions', autospec=True) @mock.patch.object(utils, 'execute', autospec=True) - @mock.patch.object(disk_utils.LOG, 'warning') + @mock.patch.object(disk_utils.LOG, 'warning', autospec=True) @mock.patch.object(utils, 'unlink_without_raise', autospec=True) @mock.patch.object(disk_utils, 'dd', diff --git a/ironic_lib/tests/test_metrics_statsd.py b/ironic_lib/tests/test_metrics_statsd.py index d328cd60..f9497a3a 100644 --- a/ironic_lib/tests/test_metrics_statsd.py +++ b/ironic_lib/tests/test_metrics_statsd.py @@ -21,6 +21,11 @@ from oslotest import base as test_base from ironic_lib import metrics_statsd +def connect(family=None, type=None, proto=None): + """Dummy function to provide signature for autospec""" + pass + + class TestStatsdMetricLogger(test_base.BaseTestCase): def setUp(self): super(TestStatsdMetricLogger, self).setUp() @@ -56,14 +61,14 @@ class TestStatsdMetricLogger(test_base.BaseTestCase): self.ml._timer('metric', 10) mock_send.assert_called_once_with(self.ml, 'metric', 10, 'ms') - @mock.patch('socket.socket') + @mock.patch('socket.socket', autospec=connect) def test_open_socket(self, mock_socket_constructor): self.ml._open_socket() mock_socket_constructor.assert_called_once_with( socket.AF_INET, socket.SOCK_DGRAM) - @mock.patch('socket.socket') + @mock.patch('socket.socket', autospec=connect) def test_send(self, mock_socket_constructor): mock_socket = mock.Mock() mock_socket_constructor.return_value = mock_socket diff --git a/ironic_lib/tests/test_utils.py b/ironic_lib/tests/test_utils.py index 99fdec2b..7f6cb57f 100644 --- a/ironic_lib/tests/test_utils.py +++ b/ironic_lib/tests/test_utils.py @@ -195,7 +195,8 @@ grep foo @mock.patch.object(utils, 'LOG', autospec=True) def _test_execute_with_log_stdout(self, log_mock, log_stdout=None): - with mock.patch.object(processutils, 'execute') as execute_mock: + with mock.patch.object( + processutils, 'execute', autospec=True) as execute_mock: execute_mock.return_value = ('stdout', 'stderr') if log_stdout is not None: utils.execute('foo', log_stdout=log_stdout)