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
6 changes: 0 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ class TestDbBackend(Enum):
PSQL = 'psql'


@pytest.fixture(autouse=True)
def _reset_runner(request):
yield
get_manager().reset_runner()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess deleting this fixture is only safe if we modify the manager fixture in the previous PR?

Copy link
Copy Markdown
Collaborator Author

@agoscinski agoscinski Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly by commit 46b6f66 we fix the bad fixture usage requirement of reseting the runner inside the test when using the manager fixture. There was however the subsequent issue with test_shutdown_worker that did not allow use to remove it in the PR #7268. Because its quite complicated requiring to understand implementation details from the python event loop, a different PR for discussion made also sense.



def pytest_collection_modifyitems(items, config):
"""Automatically generate markers for certain tests.

Expand Down
13 changes: 4 additions & 9 deletions tests/engine/daemon/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,12 @@


@pytest.mark.requires_rmq
@pytest.mark.asyncio
async def test_shutdown_worker(manager):
def test_shutdown_worker(manager):
"""Test the ``shutdown_worker`` method."""
runner = manager.get_runner()
await shutdown_worker(runner)

try:
assert runner.is_closed()
finally:
# Reset the runner of the manager, because once closed it cannot be reused by other tests.
manager._runner = None
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this is no longer needed?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manager._runner = None I mean

Copy link
Copy Markdown
Collaborator Author

@agoscinski agoscinski Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the manager fixture was properly fixed in 46b6f66 In principle we could have removed this part already in commit 46b6f66 but I just did not touch this test because I did understand then.

runner.loop.create_task(shutdown_worker(runner))
runner.loop.run_forever()
assert runner.is_closed()


@pytest.mark.usefixtures('aiida_profile_clean', 'started_daemon_client')
Expand Down
11 changes: 7 additions & 4 deletions tests/engine/test_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@

from aiida.calculations.arithmetic.add import ArithmeticAddCalculation
from aiida.engine import Process, launch
from aiida.manage import get_manager
from aiida.manage.caching import enable_caching
from aiida.orm import Int, Str, WorkflowNode


@pytest.fixture
def runner():
"""Construct and return a `Runner`."""
runner = get_manager().create_runner(poll_interval=0.5)
def runner(manager):
"""Construct and return a ``Runner``.

This fixture depends on ``manager`` so that the manager teardown resets the global profile state after the test,
clearing any shared runner state before later tests run.
"""
runner = manager.create_runner(poll_interval=0.5)
yield runner
runner.close()

Expand Down
Loading