Skip to content

Commit 324940d

Browse files
committed
fix test
1 parent 0297a4d commit 324940d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/test_loop.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,19 @@ def test_loop_basic(self) -> None:
4444
ssl_context=ssl.create_default_context(),
4545
)
4646

47-
with patch.object(mqtt_client, "_wait_for_msg") as mock_method:
48-
mock_method.side_effect = self.fake_wait_for_msg
47+
with patch.object(mqtt_client, "_wait_for_msg") as wait_for_msg_mock, \
48+
patch.object(mqtt_client, "is_connected") as is_connected_mock:
49+
50+
wait_for_msg_mock.side_effect = self.fake_wait_for_msg
51+
is_connected_mock.side_effect = lambda: True
4952

5053
time_before = time.monotonic()
5154
timeout = random.randint(3, 8)
5255
rcs = mqtt_client.loop(timeout=timeout)
5356
time_after = time.monotonic()
5457

5558
assert time_after - time_before >= timeout
56-
mock_method.assert_called()
59+
wait_for_msg_mock.assert_called()
5760

5861
# Check the return value.
5962
assert rcs is not None

0 commit comments

Comments
 (0)