Skip to content

Commit

Permalink
Reuse TypeAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed Sep 6, 2024
1 parent e428cab commit 2bebe19
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/core/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,10 @@ def test_str_default(

assert has_default_reference.__name__ in empty_context.plans
model = empty_context.plans[has_default_reference.__name__].model
assert TypeAdapter(model).validate_python({}).m is sim_motor # type: ignore
adapter = TypeAdapter(model)
assert adapter.validate_python({}).m is sim_motor # type: ignore
empty_context.device(alt_motor)
assert TypeAdapter(model).validate_python({"m": ALT_MOTOR_NAME}).m is alt_motor # type: ignore
assert adapter.validate_python({"m": ALT_MOTOR_NAME}).m is alt_motor # type: ignore


def test_nested_str_default(
Expand All @@ -388,9 +389,10 @@ def test_nested_str_default(

assert has_default_nested_reference.__name__ in empty_context.plans
model = empty_context.plans[has_default_nested_reference.__name__].model
assert TypeAdapter(model).validate_python({}).m == [sim_motor] # type: ignore
adapter = TypeAdapter(model)
assert adapter.validate_python({}).m == [sim_motor] # type: ignore
empty_context.device(alt_motor)
assert TypeAdapter(model).validate_python({"m": [ALT_MOTOR_NAME]}).m == [alt_motor] # type: ignore
assert adapter.validate_python({"m": [ALT_MOTOR_NAME]}).m == [alt_motor] # type: ignore


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

0 comments on commit 2bebe19

Please sign in to comment.