Skip to content

Commit 8e0ccc4

Browse files
committed
Tests: Adjust timing. C'est la vie.
1 parent 739f8e4 commit 8e0ccc4

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/test_cron.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,35 @@ def test_periodic_thread_success_now():
99
Proof that the `cron.PeriodicThread` implementation works as intended.
1010
"""
1111
callback = Mock()
12-
pt = PeriodicThread(callback=callback, period=0.005, name="foo", srv="SRVDUMMY", now=True, options={"foo": "bar"})
12+
pt = PeriodicThread(callback=callback, period=0.05, name="foo", srv="SRVDUMMY", now=True, options={"foo": "bar"})
1313
pt.start()
14-
delay(0.0125)
14+
delay(0.35)
1515
pt.cancel()
1616
pt.join()
1717

18-
assert callback.mock_calls == [
18+
# Timer should have been called at least two times.
19+
assert [
1920
call("SRVDUMMY", options={"foo": "bar"}),
2021
call("SRVDUMMY", options={"foo": "bar"}),
21-
call("SRVDUMMY", options={"foo": "bar"}),
22-
]
22+
] in callback.mock_calls
2323

2424

2525
def test_periodic_thread_success_not_now():
2626
"""
2727
Proof that the `cron.PeriodicThread` implementation works as intended.
2828
"""
2929
callback = Mock()
30-
pt = PeriodicThread(callback=callback, period=0.005, name="foo", srv="SRVDUMMY", now=False, options={"foo": "bar"})
30+
pt = PeriodicThread(callback=callback, period=0.05, name="foo", srv="SRVDUMMY", now=False, options={"foo": "bar"})
3131
pt.start()
32-
delay(0.0125)
32+
delay(0.35)
3333
pt.cancel()
3434
pt.join()
3535

36-
assert callback.mock_calls == [
36+
# Timer should have been called at least two times.
37+
assert [
3738
call("SRVDUMMY", options={"foo": "bar"}),
3839
call("SRVDUMMY", options={"foo": "bar"}),
39-
]
40+
] in callback.mock_calls
4041

4142

4243
def test_periodic_thread_failure(caplog):

0 commit comments

Comments
 (0)