Skip to content

Commit

Permalink
Ensure loop for 3.10 Future
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed Aug 25, 2023
1 parent b9ebda3 commit 805de2d
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/plans/test_scanspec_metadata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from asyncio import Future
from asyncio import Future, new_event_loop

import pytest
from bluesky import RunEngine
Expand All @@ -8,6 +8,13 @@
from dls_bluesky_core.plans import scan


@pytest.fixture(scope="session")
def loop():
loop = new_event_loop()
yield loop
loop.stop()


@pytest.fixture
def run_engine() -> RunEngine:
return RunEngine({})
Expand All @@ -30,7 +37,7 @@ def set_result(_, doc):
return run_engine.subscribe(name=name, func=set_result)


def test_metadata_of_simple_spec(run_engine, x):
def test_metadata_of_simple_spec(run_engine, x, loop):
det = SynGauss(
name="det",
motor=x,
Expand All @@ -41,7 +48,7 @@ def test_metadata_of_simple_spec(run_engine, x):
)
spec = Line(axis=x.name, start=1, stop=2, num=3)

start_future = Future()
start_future = loop.create_future()
tok = capture_document_return_token(start_future, run_engine, "start")
run_engine(scan([det], {x.name: x}, spec))
run_engine.unsubscribe(tok)
Expand All @@ -60,7 +67,7 @@ def test_metadata_of_simple_spec(run_engine, x):
assert start_document["detectors"] == [det.name]


def test_metadata_of_spiral_spec(run_engine, x, y):
def test_metadata_of_spiral_spec(run_engine, x, y, loop):
det = Syn2DGauss(
name="det",
motor0=x,
Expand All @@ -73,7 +80,7 @@ def test_metadata_of_spiral_spec(run_engine, x, y):
)
spec = Spiral.spaced(x.name, y.name, 0, 0, 5, 1)

start_future = Future()
start_future = loop.create_future()
tok = capture_document_return_token(start_future, run_engine, "start")
run_engine(scan([det], {x.name: x, y.name: y}, spec))
run_engine.unsubscribe(tok)
Expand Down

0 comments on commit 805de2d

Please sign in to comment.