hardware-base-test
Create or modify the shared BaseTest command helpers and class-based hardware tests in this pytest hardware automation repository. Use when adding reusable command execution, standard INFO logging, Co
SKILL.mdskills/hardware-base-test/SKILL.md
GitHubHardware Base Test
Keep reusable hardware-test behavior in tests/hardware/base.py and follow the repository
AGENTS.md rules.
Workflow
- Inspect
Dut,TestStand,Transport,CommandResult, logging configuration, and existing fake transports before changing the helper. - Expose command execution through a public device API. Never access
_transportfromBaseTestand never create SSH clients, stands, devices, or connections there. - Implement
BaseTesthelpers as typed class methods. Pass aDutexplicitly; do not introduce class or global runtime state. - When one hardware-test group needs shared behavior or fixtures, allow a group-local
base.pyinside that group's directory. Its custom base class must inherit fromtests.hardware.base.BaseTest; do not move project-specific behavior into the shared helper. - A group-local base class may declare typed pytest fixtures as class methods with
@pytest.fixture(scope="class")above@classmethod; usecls, not an instanceselfparameter. Obtain devices from the injectedTestStandthrough logical roles, return or yield them to tests, and never store the stand, devices, or other mutable runtime state on the class. Fixtures that change device state must useyieldwithtry/finally. - Import a group-specific base in test modules under the common local name
BaseTest, for examplefrom tests.hardware.recovery.base import RecoveryBaseTest as BaseTest. - Use
run_commandfor logging and execution,check_commandfor assertions, andrun_and_check_commandfor their immediate composition. ReturnCommandResultwhen callers may need additional test-specific checks. - Log command execution details through the module's standard logger at
INFOlevel. Keep numberedStepLoggercalls in tests and fixtures for significant scenario actions. Do not log commands, results, or expected values containing credentials or secrets. - Keep named domain operations on device classes. Accept arbitrary command strings only when the DUT command-line interface is itself under test.
- Read
docs/hardware-base-test.mdwhen adding preparation or cleanup fixtures, or when showing users howBaseTestcomposes with fixture-managed state. - Unit-test the helper with fake transports and a captured logger. Cover delegation, timeout, logging, successful return values, and assertion failures without network or physical hardware.
- Run the narrow unit test first, then
./scripts/ci.sh. Never run hardware tests unless the user explicitly requests them and confirms that a real stand is ready.