Skip to content

Commit 6cd8f1f

Browse files
committed
de-flake tests
1 parent f2e9635 commit 6cd8f1f

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

tests/integration/test_simulation.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ def _inner(time_: int):
3737
return _inner
3838

3939

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+
4050
@pytest.fixture(scope='module')
4151
async def sim_time_check_setup(
4252
mod_flow, mod_scheduler, mod_start, mod_one_conf,
@@ -84,9 +94,13 @@ async def sim_time_check_setup(
8494
yield schd, itasks, msg_q
8595

8696

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+
):
88100
schd, itasks, msg_q = sim_time_check_setup
89101

102+
itasks = [i for i in itasks if i.state.status != 'running']
103+
90104
# False if task status not running:
91105
assert sim_time_check(
92106
msg_q, itasks, schd.task_events_mgr.broadcast_mgr, ''
@@ -158,7 +172,7 @@ def test_sim_time_check_sets_started_time(
158172
assert one_1066.summary['started_time'] is not None
159173

160174

161-
def test_task_finishes(sim_time_check_setup, monkeytime):
175+
def test_task_finishes(sim_time_check_setup, monkeytime, q_clean):
162176
"""...and an appropriate message sent.
163177
164178
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):
167181
in unit tests.
168182
"""
169183
schd, _, msg_q = sim_time_check_setup
184+
185+
q_clean(msg_q)
186+
170187
monkeytime(0)
171188

172189
# Setup a task to fail, submit it.

0 commit comments

Comments
 (0)