@@ -37,6 +37,16 @@ def _inner(time_: int):
37
37
return _inner
38
38
39
39
40
+ @pytest .fixture
41
+ def q_clean ():
42
+ """Clear message queue to revent test interference.
43
+ """
44
+ def _inner (msg_q ):
45
+ if not msg_q .empty ():
46
+ msg_q .get ()
47
+ return _inner
48
+
49
+
40
50
@pytest .fixture (scope = 'module' )
41
51
async def sim_time_check_setup (
42
52
mod_flow , mod_scheduler , mod_start , mod_one_conf ,
@@ -84,9 +94,13 @@ async def sim_time_check_setup(
84
94
yield schd , itasks , msg_q
85
95
86
96
87
- def test_false_if_not_running (sim_time_check_setup , monkeypatch ):
97
+ def test_false_if_not_running (
98
+ sim_time_check_setup , monkeypatch , q_clean
99
+ ):
88
100
schd , itasks , msg_q = sim_time_check_setup
89
101
102
+ itasks = [i for i in itasks if i .state .status != 'running' ]
103
+
90
104
# False if task status not running:
91
105
assert sim_time_check (
92
106
msg_q , itasks , schd .task_events_mgr .broadcast_mgr , ''
@@ -158,7 +172,7 @@ def test_sim_time_check_sets_started_time(
158
172
assert one_1066 .summary ['started_time' ] is not None
159
173
160
174
161
- def test_task_finishes (sim_time_check_setup , monkeytime ):
175
+ def test_task_finishes (sim_time_check_setup , monkeytime , q_clean ):
162
176
"""...and an appropriate message sent.
163
177
164
178
Checks that failed and bar are output if a task is set to fail.
@@ -167,6 +181,9 @@ def test_task_finishes(sim_time_check_setup, monkeytime):
167
181
in unit tests.
168
182
"""
169
183
schd , _ , msg_q = sim_time_check_setup
184
+
185
+ q_clean (msg_q )
186
+
170
187
monkeytime (0 )
171
188
172
189
# Setup a task to fail, submit it.
0 commit comments