Skip to content

Commit

Permalink
Test for deprecated generator
Browse files Browse the repository at this point in the history
  • Loading branch information
callumforrester committed Jan 24, 2025
1 parent c5d7b8a commit 522ff7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
3 changes: 3 additions & 0 deletions tests/unit_tests/core/fake_plan_module.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import Generator
from typing import Any, TypeVar
from typing import Generator as DeprecatedGenerator # noqa: UP035

from bluesky.utils import Msg, MsgGenerator

Expand All @@ -15,6 +16,8 @@ def plan_d(d: int) -> Generator[Msg, None, Any]: ...
def plan_e(e: str) -> Generator[Msg, int, Any]: ...
def plan_f(f: bool) -> PlanReturningStr: ...
def plan_g(g: T) -> MsgGenerator[T]: ...
def plan_h(h: int) -> DeprecatedGenerator[Msg, None, Any]: ...
def plan_i(i: str) -> DeprecatedGenerator[Msg, int, Any]: ...


# Not plans
Expand Down
31 changes: 13 additions & 18 deletions tests/unit_tests/core/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
SIM_MOTOR_NAME = "sim"
ALT_MOTOR_NAME = "alt"
SIM_DET_NAME = "sim_det"
EXPECTED_PLANS = {
"plan_a",
"plan_b",
"plan_c",
"plan_d",
"plan_e",
"plan_f",
"plan_g",
"plan_h",
"plan_i",
}


#
Expand Down Expand Up @@ -151,15 +162,7 @@ def test_add_plan_from_module(empty_context: BlueskyContext) -> None:
import tests.unit_tests.core.fake_plan_module as plan_module

empty_context.with_plan_module(plan_module)
assert {
"plan_a",
"plan_b",
"plan_c",
"plan_d",
"plan_e",
"plan_f",
"plan_g",
} == empty_context.plans.keys()
assert EXPECTED_PLANS == empty_context.plans.keys()


def test_add_named_device(empty_context: BlueskyContext, sim_motor: SynAxis) -> None:
Expand Down Expand Up @@ -295,15 +298,7 @@ def test_add_devices_and_plans_from_modules_with_config(
"ophyd_device",
"ophyd_async_device",
} == empty_context.devices.keys()
assert {
"plan_a",
"plan_b",
"plan_c",
"plan_d",
"plan_e",
"plan_f",
"plan_g",
} == empty_context.plans.keys()
assert EXPECTED_PLANS == empty_context.plans.keys()


def test_function_spec(empty_context: BlueskyContext) -> None:
Expand Down

0 comments on commit 522ff7b

Please sign in to comment.