File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
src/dodal/testing/fixtures Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 33"""
44
55import asyncio
6+ import copy
67import os
78import threading
89import time
@@ -34,10 +35,13 @@ async def _ensure_running_bluesky_event_loop(_global_run_engine):
3435
3536@pytest .fixture ()
3637async 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" )
Original file line number Diff line number Diff 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" ]
You can’t perform that action at this time.
0 commit comments