plesty.lib.test.device_func_system

Automated function system testing utilities for Plesty devices.

Functions

_build_mock_solver(device, generator)

Build a mock op solver that returns generated response dictionaries.

auto_test(→ None)

Auto test function system for a device class.

Module Contents

plesty.lib.test.device_func_system._build_mock_solver(device, generator: plesty.lib.sim.data_generator.DataGenerator)

Build a mock op solver that returns generated response dictionaries.

Parameters:

generator (plesty.lib.sim.data_generator.DataGenerator)

plesty.lib.test.device_func_system.auto_test(device_cls: Any, *args: Any, use_mock_solver: bool = True, ignore_ops: Any = None, seed: int | None = 123, sleep_time: float = 0.1, device_kwargs: dict[str, Any] | None = None, **kwargs: Any) None

Auto test function system for a device class.

This test uses FuncParam metadata to generate valid inputs and can bind a mock solver to generate FuncOutput-shaped responses.

Parameters:
  • device_cls (Any) – The device class under test.

  • *args (Any) – Positional arguments forwarded to device_cls.

  • use_mock_solver (bool) – Bind the generated mock solver instead of calling whatever solver the module bound itself.

  • ignore_ops (Any) – Operation names to skip.

  • seed (int | None) – RNG seed for reproducible generated payloads.

  • sleep_time (float) – Delay between operations, to avoid overwhelming an instrument. Ignored under use_mock_solver — there is no instrument to pace.

  • device_kwargs (dict[str, Any] | None) – Keyword arguments forwarded to device_cls, kept apart from this function’s own. A device constructor taking a use_mock_solver or seed argument — one reference module takes the first — collides with the parameters above when the two are merged, and the call fails with “got multiple values”.

  • **kwargs (Any) – Keyword arguments forwarded to device_cls. Prefer device_kwargs for anything that might share a name.

Raises:

AssertionError – If any operation failed or returned a non-dict, or if mock mode was asked for and the device cannot accept a solver.

Return type:

None