Skip to content

Commit 8ca8906

Browse files
committed
🧪 Guard shared manager runner in tests (#7279)
Prevent tests from closing the shared manager runner directly. The original CI failure was caused by tests creating a custom runner that could still share the event loop of the cached global manager runner. When the custom runner was closed in teardown, it closed that shared loop as well. A later test then reused the cached manager runner and failed because it still pointed to the closed loop. This commit makes that contract explicit in the test fixtures. Tests are no longer allowed to close the global manager runner. Instead, tests that need shutdown semantics must use isolated runner fixtures with their own event loop. For tests that need to exercise manager-based shutdown, an isolated runner can be temporarily installed as the manager runner. The CalcJob caching test is also adjusted to clear the plugin version cache directly instead of resetting the global runner, which would now violate the stronger isolation policy.
1 parent 3d44c1d commit 8ca8906

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

tests/engine/test_runners.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@
1515

1616
from aiida.calculations.arithmetic.add import ArithmeticAddCalculation
1717
from aiida.engine import Process, launch
18-
from aiida.manage import get_manager
1918
from aiida.manage.caching import enable_caching
2019
from aiida.orm import Int, Str, WorkflowNode
2120

2221

2322
@pytest.fixture
24-
def runner():
25-
"""Construct and return a `Runner`."""
26-
runner = get_manager().create_runner(poll_interval=0.5)
23+
def runner(manager):
24+
"""Construct and return a ``Runner``.
25+
26+
This fixture depends on ``manager`` so that the manager teardown resets the global profile state after the test,
27+
clearing any shared runner state before later tests run.
28+
"""
29+
runner = manager.create_runner(poll_interval=0.5)
2730
yield runner
2831
runner.close()
2932

0 commit comments

Comments
 (0)