mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
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:
committed by
Paulus Schoutsen
parent
10c9132046
commit
4891ca1610
@@ -2,7 +2,7 @@
|
||||
# pylint: disable=protected-access,too-many-public-methods
|
||||
import logging
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import call, patch
|
||||
from datetime import datetime, timedelta
|
||||
import os
|
||||
|
||||
@@ -288,7 +288,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
|
||||
device_tracker.see(self.hass, **params)
|
||||
self.hass.block_till_done()
|
||||
assert mock_see.call_count == 1
|
||||
mock_see.assert_called_once_with(**params)
|
||||
self.assertEqual(mock_see.call_count, 1)
|
||||
self.assertEqual(mock_see.call_args, call(**params))
|
||||
|
||||
mock_see.reset_mock()
|
||||
params['dev_id'] += chr(233) # e' acute accent from icloud
|
||||
@@ -296,7 +297,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
|
||||
device_tracker.see(self.hass, **params)
|
||||
self.hass.block_till_done()
|
||||
assert mock_see.call_count == 1
|
||||
mock_see.assert_called_once_with(**params)
|
||||
self.assertEqual(mock_see.call_count, 1)
|
||||
self.assertEqual(mock_see.call_args, call(**params))
|
||||
|
||||
def test_not_write_duplicate_yaml_keys(self): \
|
||||
# pylint: disable=invalid-name
|
||||
|
||||
Reference in New Issue
Block a user