Skip to content

Commit 649a5aa

Browse files
Merge remote-tracking branch 'origin/main' into updated-jungfrau-rotation-devices
2 parents 00dd1f1 + f919ae5 commit 649a5aa

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/dodal/testing/fixtures/run_engine.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import asyncio
6+
import copy
67
import os
78
import threading
89
import time
@@ -34,10 +35,13 @@ async def _ensure_running_bluesky_event_loop(_global_run_engine):
3435

3536
@pytest.fixture()
3637
async def run_engine(_global_run_engine: RunEngine) -> AsyncGenerator[RunEngine, None]:
38+
initial_md = copy.deepcopy(_global_run_engine.md)
3739
try:
3840
yield _global_run_engine
3941
finally:
42+
# Clear subscriptions, cache, and reset metadata
4043
_global_run_engine.reset()
44+
_global_run_engine.md = initial_md
4145

4246

4347
@pytest_asyncio.fixture(scope="session", loop_scope="session")

tests/testing/fixtures/test_run_engine.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,14 @@ def test_run_engine_fixture_has_no_file_handler_leak(
3131
f"{_baseline_n_open_files} to {n_open_files} when calling the "
3232
"run_engine fixture",
3333
) from exc
34+
35+
36+
def test_add_run_engine_metadata(run_engine: RunEngine):
37+
run_engine.md["new_metadata"] = "test"
38+
39+
40+
# This will fail when tests are running in parallel if the RE's md hasn't been
41+
# correctly cleared
42+
def test_check_run_engine_metadata(run_engine: RunEngine):
43+
with pytest.raises(KeyError):
44+
run_engine.md["new_metadata"]

0 commit comments

Comments
 (0)