Fix the names of assert methods belonging to a mock
Due to mock.Mock's nature, using an undefined method will not result in an AttributeError, since the object will be created silently. This changed in Python 3.5, where accessing a member which doesn't exist will raise an AttributeError explicitly. This uncovered a couple of bugs in the test suite. Change-Id: Idbfa92d82b01ff4710dfdd4556500b5c61d20db6
This commit is contained in:
parent
6d69d8a847
commit
0073c7b86b
@ -42,7 +42,7 @@ class EC2ServiceTest(unittest.TestCase):
|
||||
response = self._service.load()
|
||||
mock_check_metadata_ip_route.assert_called_once_with(
|
||||
CONF.ec2_metadata_base_url)
|
||||
mock_get_host_name.assert_called_once()
|
||||
mock_get_host_name.assert_called_once_with()
|
||||
if side_effect is Exception:
|
||||
self.assertFalse(response)
|
||||
else:
|
||||
|
@ -209,8 +209,9 @@ class TestOpenNebulaService(_TestOpenNebulaService):
|
||||
if level > 1:
|
||||
(mock_osutils.get_volume_label
|
||||
.assert_called_once_with(fakes["drive"]))
|
||||
mock_os_path.join.assert_called_once()
|
||||
mock_os_path.isfile.assert_called_once()
|
||||
mock_os_path.join.assert_called_once_with(
|
||||
"mount_point", opennebulaservice.CONTEXT_FILE)
|
||||
mock_os_path.isfile.assert_called_once_with("fake_path")
|
||||
# check response and members
|
||||
if level in (1, 2):
|
||||
self.assertFalse(ret)
|
||||
|
@ -1404,7 +1404,7 @@ class TestWindowsUtils(testutils.CloudbaseInitTestBase):
|
||||
|
||||
response = self._winutils.get_dhcp_hosts_in_use()
|
||||
|
||||
mock_get_adapter_addresses.assert_called()
|
||||
mock_get_adapter_addresses.assert_called_once_with()
|
||||
self.assertEqual([('fake mac address', 'fake dhcp server')], response)
|
||||
|
||||
@mock.patch('cloudbaseinit.osutils.windows.WindowsUtils'
|
||||
|
@ -155,7 +155,7 @@ class InitManagerTest(unittest.TestCase):
|
||||
|
||||
self._init.configure_host()
|
||||
|
||||
self.osutils.wait_for_boot_completion.assert_called_once()
|
||||
self.osutils.wait_for_boot_completion.assert_called_once_with()
|
||||
mock_get_metadata_service.assert_called_once_with()
|
||||
fake_service.get_name.assert_called_once_with()
|
||||
mock_check_os_requirements.assert_called_once_with(self.osutils,
|
||||
|
Loading…
x
Reference in New Issue
Block a user