Testing with Zelos SDK¶
The Zelos SDK includes a concise, pytest-based framework for hardware-in-the-loop testing, system validation, and real-time data checks.
Quick Start¶
# Install
pip install zelos-sdk
# Stream live to the Agent
pytest --zelos-trace --log-cli --log-cli-level=INFO
# Stream + record to files (artifacts dir required)
pytest --zelos-trace --zelos-trace-file --zelos-local-artifacts-dir=./artifacts
Minimal test:
import zelos_sdk
motor = zelos_sdk.TraceSourceCacheLast("motor")
motor.add_event("status", [
zelos_sdk.TraceEventFieldMetadata("rpm", zelos_sdk.DataType.Float64),
zelos_sdk.TraceEventFieldMetadata("current", zelos_sdk.DataType.Float64, "A"),
])
def test_reaches_target(check):
check.that(motor.status.rpm, ">", 1900, within_duration_s=0.5)
check.that(motor.status.current, "<", 50, for_duration_s=2.0)
What You Get¶
- Checker: expressive, time-aware checks with visual “checkerboard” output
- Recording: automatic
.trz
files per function/class/module/session - Logging: capture Python logs as trace events and stream to the Agent
- Reports: auto-linked trace files in HTML reports (auto-configured if
pytest-html
is installed)
Notes:
- Plugins are auto-registered; no
pytest_plugins
setup required - When recording, pass
--zelos-local-artifacts-dir=./artifacts
How it works¶
- Plugins auto-load via
pytest11
entry point (pytest-zelos-plugins
), so nopytest_plugins
boilerplate. - Config plugin creates
--zelos-local-artifacts-dir
(if provided) and formats--zelos-artifact-basename
, then triggerspytest_zelos_configure
. -
Trace plugin:
-
Streaming:
--zelos-trace
+--zelos-trace-url
initialize the SDK session. - Recording:
--zelos-trace-file
+ scope fixtures write.trz
files to the artifacts dir. - Logging: forward Python logs (
--zelos-trace-logging
) or print events to stdout (--zelos-trace-stdout
). - HTML links: adds
.trz
links topytest-html
reports when installed. - Report plugin: if
pytest-html
is installed and no--html
is provided, auto-writes{artifact_basename}-report.html
in the artifacts dir and enables self-contained HTML. - Checker plugin: provides the
check
fixture for time-aware, readable assertions.
Configure¶
- Minimal pytest.ini
- Recording (artifacts dir required): see Trace Recording
- All options: see Configuration
Copy-paste pytest.ini (stream + record + logs)¶
[pytest]
addopts =
-sv
--zelos-trace
--zelos-trace-url=grpc://localhost:2300
--zelos-trace-file
--zelos-trace-file-scope=function
--zelos-local-artifacts-dir=./artifacts
--zelos-trace-logging
--zelos-trace-logging-level=info
--html=artifacts/report.html
log_cli = true
log_cli_level = INFO
Next Steps¶
-
Write clear, time-aware checks without asserts
-
Capture
.trz
files and link them in reports -
Built-in fixtures and how they activate
-
All CLI options and hooks