Removing calls to mock.assert_called_once_with (#3896)
If a mock's assert_called_once_with method is misspelled (e.g. asert_called_once_with) then the test will appear as passing. Therefore, this commit removes all instances of assert_called_once_with calls and replaces them with two assertions:
self.assertEqual(mock.call_count, 1)
self.assertEqual(mock.call_args, mock.call(call_args))
This commit is contained in:
1 parent
10c9132046
commit
4891ca1610
18 files changed
+308
-109
No files matched your search
@@ -65,7 +65,8 @@ class TestMfiSwitch(unittest.TestCase):
|
||||
def test_update(self):
|
||||
"""Test update."""
|
||||
self.switch.update()
|
||||
self.port.refresh.assert_called_once_with()
|
||||
self.assertEqual(self.port.refresh.call_count, 1)
|
||||
self.assertEqual(self.port.refresh.call_args, mock.call())
|
||||
|
||||
def test_update_with_target_state(self):
|
||||
"""Test update with target state."""
|
||||
@@ -82,13 +83,15 @@ class TestMfiSwitch(unittest.TestCase):
|
||||
def test_turn_on(self):
|
||||
"""Test turn_on."""
|
||||
self.switch.turn_on()
|
||||
self.port.control.assert_called_once_with(True)
|
||||
self.assertEqual(self.port.control.call_count, 1)
|
||||
self.assertEqual(self.port.control.call_args, mock.call(True))
|
||||
self.assertTrue(self.switch._target_state)
|
||||
|
||||
def test_turn_off(self):
|
||||
"""Test turn_off."""
|
||||
self.switch.turn_off()
|
||||
self.port.control.assert_called_once_with(False)
|
||||
self.assertEqual(self.port.control.call_count, 1)
|
||||
self.assertEqual(self.port.control.call_args, mock.call(False))
|
||||
self.assertFalse(self.switch._target_state)
|
||||
|
||||
def test_current_power_mwh(self):
|
||||
|
||||
Reference in new issue
Block a user