Lightweight telnet-based embedded device test framework
Project description
Py-Tester
Small test framework that discovers TestSuite objects from testcases/.
Quick start
-
Configure device connection in
config.json(repo root) or use CLI args to override. -
Add test modules in
testcases/— each module should exposeTestSuiteobjects at module level. -
Run:
python main.py
CLI precedence and config
- The framework loads device info from
config.jsonby default. - Command-line options override
config.jsonvalues. Supported flags:--config/-c: path to config file--host,--port,--username,--password--prompt,--login-prompt,--passwd-prompt--dry-run: do not open real network connections (uses DummyDevice)--filter/-f: comma-separated case id patterns (supports*wildcard). Example:--filter tc_*will run cases whosecase_idmatches the pattern.--level: levels to run; accepts a comma-separated list and ranges. Examples:--level 1or--level 1-2,4.--report: output format,plainorjson(defaultplain).--report-file: write report to the given file path instead of stdout.--cases-dir: package name or directory path wheretestcaseslive. Default:testcases(project subdirectory). Example:--cases-dir ./my_testsor--cases-dir my_tests_pkg.
Test module authoring (summary)
- Define
TestCaseandTestSuiteobjects at module scope; the framework auto-discovers them. - Use module-level hook functions if needed:
suite_setup(dev)/suite_teardown(dev)— run once per suitesetup(dev)/teardown(dev)— run for each case in the module
- Ensure
suite_idis unique.
Examples and more details: see testcases/README.md.
Examples
-
Run dry-run with JSON report saved to
out.json:python -m omtest --dry-run --report json --report-file out.json
-
Run only level 2 tests and filter case ids that start with
tc_:python -m omtest --host 192.0.2.10 --level 2 --filter tc_*
Capabilities
Tests can declare required device capabilities using the requires_capabilities decorator exported by the package. If the running device does not provide the required capabilities the test case will be skipped.
Example usage in a test module:
from omtest.capabilities import requires_capabilities
@requires_capabilities('ftp', 'judge')
def test_judge_with_ftp(dev):
# this test will only run if the device reports both 'ftp' and 'judge' capabilities
...
Devices should implement has_capability(cap) or expose a capabilities set. The provided DummyDevice used with --dry-run includes a small set of capabilities for demonstration.
Configuration-driven capability checks
You can instruct the test runner to probe a device for capabilities at connect time by adding a capability mapping under the device section in config.json. The mapper keys are capability names and the value is a list of checks. Each check may be an object with cmd and expect, or a two-element array [cmd, expect]. The expect entry can be a string or a list of strings; when a list is provided at least one element must match the command output. All checks defined for a capability must pass (logical AND) for the capability to be considered present.
Example config.json snippet:
{
"device": {
"host": "192.0.2.10",
"port": 23,
"username": "admin",
"password": "secret",
"capability": {
"ftp": [
{ "cmd": "display version", "expect": "FTP server" }
],
"judge": [
["display judge brief", "Judge Mode : ACM"]
],
"local-user": [
{ "cmd": "display user", "expect": ["root", "admin"] }
]
}
}
}
Notes:
- If
expectis omitted, a non-empty command output is treated as success for that check. - Matching is substring-based. If you need regex matching or more complex logic, extend
pytester.devices.CapacityManager.collectaccordingly. - In
--dry-runmodeDummyDeviceprovides some example capabilities; capability checks are not executed against network devices in dry-run.
Build & Publish
Build a source and wheel distribution locally:
python -m pip install --upgrade build wheel twine
python -m build
Check the produced files in the dist/ directory. To upload to PyPI (test PyPI recommended first):
# upload to Test PyPI
python -m twine upload --repository testpypi dist/*
# upload to PyPI
python -m twine upload dist/*
Before uploading, update setup.cfg metadata (author, email, url, version) as appropriate.
Build and publish to PyPI
Build source and wheel distributions:
pip install --upgrade build wheel twine
python -m build
Upload to Test PyPI (recommended first):
twine upload --repository testpypi dist/*
Upload to PyPI:
twine upload dist/*
Notes: Notes:
- Version single-source: package reads
version = attr: omtest.__version__fromsetup.cfg. To bump the package version, update the__version__variable inomtest/__init__.py. - After updating the version, run the build commands above and upload the new distribution.
- Add any runtime dependencies to
setup.cfgunderinstall_requires.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file omtest-0.0.1.tar.gz.
File metadata
- Download URL: omtest-0.0.1.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d20244051cb077ccad9946a9921e3a2eadbb895cd9bfc94cbd75341f996a4ff6
|
|
| MD5 |
95796054d91250bf8196d30d502cc2c0
|
|
| BLAKE2b-256 |
7d50a2ac02603f672137c4046b68a2a943f54e24318e7724de078127a61bc7fa
|
File details
Details for the file omtest-0.0.1-py3-none-any.whl.
File metadata
- Download URL: omtest-0.0.1-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de1498d079732cae8a2c0d268852c3915f7e12438938bc9a1056ddeae9d9e5d1
|
|
| MD5 |
ea5dc9dc8c89f6b145e94c1fb620fcf6
|
|
| BLAKE2b-256 |
d7564193e90520f806f7cc7fd703ccc41a6f9305dc62ac3bbb1225b0a2c496bd
|