Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dev = [
"isort>=5",
"mock",
"pytest",
"pytest-asyncio<1.0",
"pytest-asyncio",
"pytest-mock",
"pytest-random-order",
"mypy",
Expand Down
3 changes: 0 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ async def _fake_request(resp_status, method, url, *args, **kwargs):
return resp


@pytest.mark.asyncio
@pytest.fixture(scope="function")
async def fake_session():
session = scriptworker_session()
Expand All @@ -85,7 +84,6 @@ async def fake_session():
await session.close()


@pytest.mark.asyncio
@pytest.fixture(scope="function")
async def fake_session_500():
session = scriptworker_session()
Expand All @@ -94,7 +92,6 @@ async def fake_session_500():
await session.close()


@pytest.mark.asyncio
@pytest.fixture(scope="function")
async def fake_session_404():
session = scriptworker_session()
Expand Down
10 changes: 5 additions & 5 deletions tests/test_cot_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -2222,7 +2222,7 @@ async def maybe_die(*args):
# verify_cot_cmdln {{{1
@pytest.mark.parametrize("args", (("x", "--task-type", "signing", "--cleanup"), ("x", "--task-type", "balrog")))
@pytest.mark.parametrize("use_github_token", (False, True))
def test_verify_cot_cmdln(chain, args, tmpdir, mocker, event_loop, use_github_token, monkeypatch):
def test_verify_cot_cmdln(chain, args, tmpdir, mocker, use_github_token, monkeypatch):
if use_github_token:
monkeypatch.setenv("SCRIPTWORKER_GITHUB_OAUTH_TOKEN", "sometoken")
context = MagicMock()
Expand Down Expand Up @@ -2250,7 +2250,7 @@ def cot(*args, **kwargs):
mocker.patch.object(cotverify, "retry_get_task_definition", new=noop_async)
mocker.patch.object(cotverify, "verify_chain_of_trust", new=noop_async)

cotverify.verify_cot_cmdln(args=args, event_loop=event_loop)
cotverify.verify_cot_cmdln(args=args)


# create_test_workdir {{{1
Expand All @@ -2275,7 +2275,7 @@ async def fake_task(task_id):


@pytest.mark.parametrize("exists, overwrite, raises", ((True, True, False), (False, False, False), (False, True, False), (True, False, True)))
def test_create_test_workdir(mocker, event_loop, tmpdir, exists, overwrite, raises):
def test_create_test_workdir(mocker, tmpdir, exists, overwrite, raises):
"""``create_test_workdir`` fails if ``path`` exists and ``--overwrite`` isn't
passed. Otherwise we call ``_async_create_test_workdir`` with the appropriate
args.
Expand All @@ -2294,9 +2294,9 @@ async def fake_create(*args):
makedirs(work_dir)
if raises:
with pytest.raises(SystemExit):
cotverify.create_test_workdir(args=args, event_loop=event_loop)
cotverify.create_test_workdir(args=args)
else:
cotverify.create_test_workdir(args=args, event_loop=event_loop)
cotverify.create_test_workdir(args=args)


@pytest.mark.parametrize(
Expand Down
10 changes: 6 additions & 4 deletions tests/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def context(rw_context):


# main {{{1
def test_main(mocker, context, event_loop):
def test_main(mocker, context):
config = dict(context.config)
config["poll_interval"] = 1
creds = {"fake_creds": True}
Expand All @@ -57,15 +57,16 @@ async def foo(arg, credentials):
mocker.patch.object(worker, "async_main", new=foo)
mocker.patch.object(sys, "argv", new=["x", tmp])
with pytest.raises(ScriptWorkerException):
worker.main(event_loop=event_loop)
worker.main()
finally:
os.remove(tmp)


@pytest.mark.parametrize("running", (True, False))
def test_main_running_sigterm(mocker, context, event_loop, running):
def test_main_running_sigterm(mocker, context, running):
"""Test that sending SIGTERM causes the main loop to stop after the next
call to async_main."""
event_loop = asyncio.get_event_loop()
run_tasks_cancelled = event_loop.create_future()

class MockRunTasks:
Expand Down Expand Up @@ -97,9 +98,10 @@ async def async_main(internal_context, _):


@pytest.mark.parametrize("running", (True, False))
def test_main_running_sigusr1(mocker, context, event_loop, running):
def test_main_running_sigusr1(mocker, context, running):
"""Test that sending SIGUSR1 causes the main loop to stop after the next
call to async_main without cancelling the task."""
event_loop = asyncio.get_event_loop()
run_tasks_cancelled = event_loop.create_future()

class MockRunTasks:
Expand Down