Skip to content

Commit 20e2082

Browse files
committed
fix: test failures around missing 'event_loop' fixture
Caused by the recent pytest-asyncio 1.0 release, which included pytest-dev/pytest-asyncio#1106. This is probably not the best fix - but it unbreaks things for now.
1 parent ec94733 commit 20e2082

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

tests/test_cot_verify.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,7 +2171,7 @@ async def maybe_die(*args):
21712171
# verify_cot_cmdln {{{1
21722172
@pytest.mark.parametrize("args", (("x", "--task-type", "signing", "--cleanup"), ("x", "--task-type", "balrog")))
21732173
@pytest.mark.parametrize("use_github_token", (False, True))
2174-
def test_verify_cot_cmdln(chain, args, tmpdir, mocker, event_loop, use_github_token, monkeypatch):
2174+
def test_verify_cot_cmdln(chain, args, tmpdir, mocker, _function_event_loop, use_github_token, monkeypatch):
21752175
if use_github_token:
21762176
monkeypatch.setenv("SCRIPTWORKER_GITHUB_OAUTH_TOKEN", "sometoken")
21772177
context = MagicMock()
@@ -2199,7 +2199,7 @@ def cot(*args, **kwargs):
21992199
mocker.patch.object(cotverify, "retry_get_task_definition", new=noop_async)
22002200
mocker.patch.object(cotverify, "verify_chain_of_trust", new=noop_async)
22012201

2202-
cotverify.verify_cot_cmdln(args=args, event_loop=event_loop)
2202+
cotverify.verify_cot_cmdln(args=args, event_loop=_function_event_loop)
22032203

22042204

22052205
# create_test_workdir {{{1
@@ -2224,7 +2224,7 @@ async def fake_task(task_id):
22242224

22252225

22262226
@pytest.mark.parametrize("exists, overwrite, raises", ((True, True, False), (False, False, False), (False, True, False), (True, False, True)))
2227-
def test_create_test_workdir(mocker, event_loop, tmpdir, exists, overwrite, raises):
2227+
def test_create_test_workdir(mocker, _function_event_loop, tmpdir, exists, overwrite, raises):
22282228
"""``create_test_workdir`` fails if ``path`` exists and ``--overwrite`` isn't
22292229
passed. Otherwise we call ``_async_create_test_workdir`` with the appropriate
22302230
args.
@@ -2243,9 +2243,9 @@ async def fake_create(*args):
22432243
makedirs(work_dir)
22442244
if raises:
22452245
with pytest.raises(SystemExit):
2246-
cotverify.create_test_workdir(args=args, event_loop=event_loop)
2246+
cotverify.create_test_workdir(args=args, event_loop=_function_event_loop)
22472247
else:
2248-
cotverify.create_test_workdir(args=args, event_loop=event_loop)
2248+
cotverify.create_test_workdir(args=args, event_loop=_function_event_loop)
22492249

22502250

22512251
@pytest.mark.parametrize(

tests/test_worker.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def context(rw_context):
3737

3838

3939
# main {{{1
40-
def test_main(mocker, context, event_loop):
40+
def test_main(mocker, context, _function_event_loop):
4141
config = dict(context.config)
4242
config["poll_interval"] = 1
4343
creds = {"fake_creds": True}
@@ -56,16 +56,16 @@ async def foo(arg, credentials):
5656
mocker.patch.object(worker, "async_main", new=foo)
5757
mocker.patch.object(sys, "argv", new=["x", tmp])
5858
with pytest.raises(ScriptWorkerException):
59-
worker.main(event_loop=event_loop)
59+
worker.main(event_loop=_function_event_loop)
6060
finally:
6161
os.remove(tmp)
6262

6363

6464
@pytest.mark.parametrize("running", (True, False))
65-
def test_main_running_sigterm(mocker, context, event_loop, running):
65+
def test_main_running_sigterm(mocker, context, _function_event_loop, running):
6666
"""Test that sending SIGTERM causes the main loop to stop after the next
6767
call to async_main."""
68-
run_tasks_cancelled = event_loop.create_future()
68+
run_tasks_cancelled = _function_event_loop.create_future()
6969

7070
class MockRunTasks:
7171
@staticmethod
@@ -86,20 +86,20 @@ async def async_main(internal_context, _):
8686
json.dump(context.config, fh)
8787
mocker.patch.object(worker, "async_main", new=async_main)
8888
mocker.patch.object(sys, "argv", new=["x", tmp])
89-
worker.main(event_loop=event_loop)
89+
worker.main(event_loop=_function_event_loop)
9090
finally:
9191
os.remove(tmp)
9292

9393
if running:
94-
event_loop.run_until_complete(run_tasks_cancelled)
94+
_function_event_loop.run_until_complete(run_tasks_cancelled)
9595
assert run_tasks_cancelled.result()
9696

9797

9898
@pytest.mark.parametrize("running", (True, False))
99-
def test_main_running_sigusr1(mocker, context, event_loop, running):
99+
def test_main_running_sigusr1(mocker, context, _function_event_loop, running):
100100
"""Test that sending SIGUSR1 causes the main loop to stop after the next
101101
call to async_main without cancelling the task."""
102-
run_tasks_cancelled = event_loop.create_future()
102+
run_tasks_cancelled = _function_event_loop.create_future()
103103

104104
class MockRunTasks:
105105
@staticmethod
@@ -120,7 +120,7 @@ async def async_main(internal_context, _):
120120
json.dump(context.config, fh)
121121
mocker.patch.object(worker, "async_main", new=async_main)
122122
mocker.patch.object(sys, "argv", new=["x", tmp])
123-
worker.main(event_loop=event_loop)
123+
worker.main(event_loop=_function_event_loop)
124124
finally:
125125
os.remove(tmp)
126126

0 commit comments

Comments
 (0)