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
@@ -125,7 +125,8 @@ class TestSonosMediaPlayer(unittest.TestCase):
|
||||
device = sonos.DEVICES[-1]
|
||||
partymodeMock.return_value = True
|
||||
device.group_players()
|
||||
partymodeMock.assert_called_once_with()
|
||||
self.assertEqual(partymodeMock.call_count, 1)
|
||||
self.assertEqual(partymodeMock.call_args, mock.call())
|
||||
|
||||
@mock.patch('soco.SoCo', new=SoCoMock)
|
||||
@mock.patch.object(SoCoMock, 'unjoin')
|
||||
@@ -135,7 +136,8 @@ class TestSonosMediaPlayer(unittest.TestCase):
|
||||
device = sonos.DEVICES[-1]
|
||||
unjoinMock.return_value = True
|
||||
device.unjoin()
|
||||
unjoinMock.assert_called_once_with()
|
||||
self.assertEqual(unjoinMock.call_count, 1)
|
||||
self.assertEqual(unjoinMock.call_args, mock.call())
|
||||
|
||||
@mock.patch('soco.SoCo', new=SoCoMock)
|
||||
@mock.patch.object(soco.snapshot.Snapshot, 'snapshot')
|
||||
@@ -145,7 +147,8 @@ class TestSonosMediaPlayer(unittest.TestCase):
|
||||
device = sonos.DEVICES[-1]
|
||||
snapshotMock.return_value = True
|
||||
device.snapshot()
|
||||
snapshotMock.assert_called_once_with()
|
||||
self.assertEqual(snapshotMock.call_count, 1)
|
||||
self.assertEqual(snapshotMock.call_args, mock.call())
|
||||
|
||||
@mock.patch('soco.SoCo', new=SoCoMock)
|
||||
@mock.patch.object(soco.snapshot.Snapshot, 'restore')
|
||||
@@ -155,4 +158,5 @@ class TestSonosMediaPlayer(unittest.TestCase):
|
||||
device = sonos.DEVICES[-1]
|
||||
restoreMock.return_value = True
|
||||
device.restore()
|
||||
restoreMock.assert_called_once_with(True)
|
||||
self.assertEqual(restoreMock.call_count, 1)
|
||||
self.assertEqual(restoreMock.call_args, mock.call(True))
|
||||
Reference in new issue
Block a user