Skip to content

Commit d2775db

Browse files
committed
Minor refactor of time.sleep() used in tests for consistency.
1 parent 22f0b90 commit d2775db

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

test/timer/exception_handling/soft_error/stop_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from os import linesep
33

44
import pytest
5+
from _constant.interval import ULTRA_SHORT_INTERVAL
56
from _helper import operating_system
67
from _helper.random import random_thread_name, random_thread_name_but_not
78
from _helper.timer import ensure_all_timer_threads_are_stopped
@@ -17,7 +18,7 @@ def test_timer_stop_unknown_thread_soft_error_with_default_and_custom_thread(cap
1718
custom_thread = random_thread_name()
1819
timer = ensure_all_timer_threads_are_stopped()
1920
timer.start()
20-
time.sleep(0.001)
21+
time.sleep(ULTRA_SHORT_INTERVAL)
2122
timer.stop(thread=custom_thread)
2223
terminal_output, _ = capfd.readouterr()
2324
assert terminal_output == \
@@ -35,7 +36,7 @@ def test_timer_stop_unknown_thread_soft_error_with_multiple_custom_threads(capfd
3536
custom_thread_2 = random_thread_name_but_not(custom_thread_1)
3637
timer = ensure_all_timer_threads_are_stopped()
3738
timer.start(thread=custom_thread_1)
38-
time.sleep(0.001)
39+
time.sleep(ULTRA_SHORT_INTERVAL)
3940
timer.stop(thread=custom_thread_2)
4041
terminal_output, _ = capfd.readouterr()
4142
assert terminal_output == \

test/timer/successful_output/decimals_2_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re
22
import time
33

4+
from _constant.interval import ULTRA_SHORT_INTERVAL
45
from _helper.terminal_output import successful_output_regex
56
from _helper.timer import ensure_all_timer_threads_are_stopped
67

@@ -12,7 +13,7 @@ def test_timer_decimals_output(capfd: object) -> None:
1213
ensure_all_timer_threads_are_stopped()
1314
for decimals in range(MINIMUM, MAXIMUM + 1):
1415
with Timer(decimals=decimals):
15-
time.sleep(0.001)
16+
time.sleep(ULTRA_SHORT_INTERVAL)
1617
terminal_output, _ = capfd.readouterr()
1718
expected_output_regex = successful_output_regex(decimals=decimals)
1819
assert re.fullmatch(expected_output_regex, terminal_output)

test/timer/successful_output/thread_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re
22
import time
33

4+
from _constant.interval import ULTRA_SHORT_INTERVAL
45
from _helper.random import random_thread_name
56
from _helper.terminal_output import successful_output_regex
67
from _helper.timer import ensure_all_timer_threads_are_stopped
@@ -12,7 +13,7 @@ def test_timer_thread_output(capfd: object) -> None:
1213
ensure_all_timer_threads_are_stopped()
1314
custom_thread = random_thread_name()
1415
with Timer(thread=custom_thread):
15-
time.sleep(0.001)
16+
time.sleep(ULTRA_SHORT_INTERVAL)
1617
terminal_output, _ = capfd.readouterr()
1718
expected_output_regex = successful_output_regex(thread=custom_thread)
1819
assert re.fullmatch(expected_output_regex, terminal_output)

0 commit comments

Comments
 (0)