Skip to content

Commit 2873910

Browse files
committed
Increase test timeout
1 parent a1fe0a7 commit 2873910

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

conftest.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,20 @@
2727
]:
2828
sys.modules[module] = Mock()
2929

30+
3031
# use gpiozero fake pins
3132
environ["GPIOZERO_PIN_FACTORY"] = "mock"
3233

3334

3435
@pytest.fixture
35-
def oled_mocks():
36+
def zmq_poller_mock():
37+
poller_mock = Mock()
38+
poller_mock.poll.return_value = []
39+
sys.modules["zmq"].Poller.return_value = poller_mock
40+
41+
42+
@pytest.fixture
43+
def oled_mocks(zmq_poller_mock):
3644
SIZE = (128, 64)
3745
MODE = "1"
3846
SPI_BUS = 0

tests/test_ptdm.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def setUp(self):
2222
def test_correct_callback_called_when_message_is_published(self):
2323
from pitop.common.ptdm import Message, PTDMSubscribeClient
2424

25-
self.poller_mock.poll.return_value = [1]
25+
self.poller_mock.poll.return_value = [2]
2626

2727
def callback_without_args():
2828
callback_without_args.counter += 1
@@ -43,14 +43,19 @@ def callback_with_args():
4343
)
4444
client.start_listening()
4545

46+
assert callback_without_args.counter == 0
47+
assert callback_with_args.counter == 0
48+
49+
# Emit event that doesn't use an argument
4650
self.socket_mock.recv_string.return_value = f"{Message.PUB_LOW_BATTERY_WARNING}"
47-
wait_until(lambda: callback_without_args.counter > 0, timeout=3)
51+
wait_until(lambda: callback_without_args.counter > 0, timeout=5)
4852
assert callback_with_args.counter == 0
4953

54+
# Emit event that uses an argument
5055
self.socket_mock.recv_string.return_value = (
5156
f"{Message.PUB_BRIGHTNESS_CHANGED}|1"
5257
)
53-
wait_until(lambda: callback_with_args.counter > 0, timeout=3)
58+
wait_until(lambda: callback_with_args.counter > 0, timeout=5)
5459

5560
client.stop_listening()
5661

@@ -59,6 +64,7 @@ def test_callback_not_included_if_has_wrong_signature(self):
5964

6065
self.socket_mock.recv_string.return_value = f"{Message.PUB_LOW_BATTERY_WARNING}"
6166

67+
# Callback should have only 1 argument
6268
def callback(x, y):
6369
callback.counter += 1
6470

@@ -71,6 +77,7 @@ def callback(x, y):
7177
}
7278
)
7379

80+
# Callback wasn't saved
7481
assert client._callback_funcs.get(Message.PUB_LOW_BATTERY_WARNING) is None
7582

7683
def test_subscribe_client_cleanup_closes_socket(self):

0 commit comments

Comments
 (0)