Skip to main content

pytest-hwcontract

Judge hardware captures against hwcontract contracts as ordinary pytest tests. A FAIL, MARGINAL or MISSING edge is a failing test with the rendered verdict table in the message, so JUnit and CI show exactly which edge failed, the measured value, and the delta.

pip install pytest-hwcontract

Use

def test_strip(hwcontract):
    obs = hwcontract.capture_csv("captures/strip.csv", samplerate=24_000_000)
    hwcontract.timing("ws2812b", obs)          # bundled contract by name
    hwcontract.timing("contracts/esc.contract.yaml", obs)   # or a path

def test_boot(hwcontract):
    hwcontract.serial("boot", open("boot.log").read())

Contracts resolve as: an existing path, then --hwcontract-root <dir>, then the 28 contracts bundled with hwcontract by name.

capture_csv buckets pulses with WS2812-family thresholds by default. Pass the protocol's own for anything else, e.g. DShot600: capture_csv(path, samplerate=24_000_000, high_split=937, low_split=730, reset_ns=1800).

A failing verdict reads like the CLI's:

AssertionError: verdict: FAIL  contract 3b714248c15e  observations fcc02d743809  hwcontract 0.6.1
edge        typ   actual  status    hint
------------------------------------------------------------
T0H         400      333  PASS
T0L         850      792  PASS
T1H         800      708  MARGINAL  only 58ns from min; nudge toward typ 800
T1L         450      583  MARGINAL  within one sample (41.7ns) of max; capture at a higher samplerate to resolve
RESET     50000    60583  PASS

Why marginal fails

In spec but rail-hugging works on your bench and dies in the field. The judge fails the test on MARGINAL by design; that is the whole point of gating CI on wire-level measurements.

Metadata

Release files for pytest-hwcontract 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-hwcontract 0.1.4
File Size Uploaded Provenance Actions
pytest_hwcontract-0.1.4.tar.gz 5.6 kB With provenance Details for pytest_hwcontract-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-hwcontract 0.1.4
File Interpreter ABI Platform Actions
pytest_hwcontract-0.1.4-py3-none-any.whl Python 3 none any Details for pytest_hwcontract-0.1.4-py3-none-any.whl

Total release size: 10.2 kB

Release files / pytest_hwcontract-0.1.4.tar.gz

Download URL pytest_hwcontract-0.1.4.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4f08e2301d4454bf43ecb7325ffcb49c45e7b7f7e9074d259e5c6fc734c7e681
BLAKE2b-256 checksum
How to use checksums
12e36443aea3b1b79ba9cc1b870c249d6cecdd1010a6febbe36fbaf5a83c938c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / pytest_hwcontract-0.1.4-py3-none-any.whl

Download URL pytest_hwcontract-0.1.4-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73436dd294dac9133ed3e903dc5c77662c8cbf763c951812a05f3c3b0e6c64b3
BLAKE2b-256 checksum
How to use checksums
12bb87e5b3376587e495ca2c405f5cbec82171c8400ea9f27152291c8a16f920
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for pytest-hwcontract 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytest_hwcontract-0.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page