suite.register¶
register_suite() — class decorator that registers an OttoSuite as a Typer subcommand.
Registration happens at class-definition time (import time). cli/test.py
reads _SUITE_REGISTRY after configmodule has finished loading (which is
also when this module is first imported via test-file auto-scan) and adds the
pre-built sub-Typers to suite_app.
No circular imports: this module never imports from otto.cli.test at module
level. The runner function uses a lazy import so the actual test execution can
reach run_suite only when the CLI command is invoked, by which time
cli/test.py is fully loaded.
- otto.suite.register.register_suite(*args: Any, **kwargs: Any) Callable[[type], type]¶
Class decorator that registers an OttoSuite subclass as a
suite_appsubcommand.Usage:
from otto import options @register_suite() class TestMyDevice(OttoSuite): """Run device validation tests.""" @options class Options(RepoOptions): firmware: str = "latest" check_interfaces: bool = True async def test_something(self, suite_options): opts = suite_options # fully-typed Options instance ...The decorated class is returned unchanged. The decorator only has a side-effect: it builds a Typer sub-app from the class’s
Optionsinner class (if present) and appends it to_SUITE_REGISTRY.cli/test.pyreads the registry at module load time and adds the sub-apps tosuite_app.