1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-22 11:59:34 +00:00

Merge multiple context managers in tests (#48146)

This commit is contained in:
Franck Nijhof
2021-03-27 09:17:15 +01:00
committed by GitHub
parent 79af18a8ab
commit ad13a9295e
33 changed files with 590 additions and 627 deletions

View File

@@ -220,11 +220,12 @@ class TestGraphite(unittest.TestCase):
runs.append(1)
return event
with mock.patch.object(self.gf, "_queue") as mock_queue:
with mock.patch.object(self.gf, "_report_attributes") as mock_r:
mock_queue.get.side_effect = fake_get
self.gf.run()
# Twice for two events, once for the stop
assert mock_queue.task_done.call_count == 3
assert mock_r.call_count == 1
assert mock_r.call_args == mock.call("entity", event.data["new_state"])
with mock.patch.object(self.gf, "_queue") as mock_queue, mock.patch.object(
self.gf, "_report_attributes"
) as mock_r:
mock_queue.get.side_effect = fake_get
self.gf.run()
# Twice for two events, once for the stop
assert mock_queue.task_done.call_count == 3
assert mock_r.call_count == 1
assert mock_r.call_args == mock.call("entity", event.data["new_state"])