Skip to main content

chumicro-pytest-device

Pytest plugin that runs your tests on a real CircuitPython or MicroPython board.

Drop tests under any functional_tests/ directory and the plugin intercepts collection: stages your library + test source onto the connected board via chumicro-deploy, executes the test in the device runtime, parses the result back, and fails / passes the host-side pytest with the on-device outcome. Reads device targets from your devices.yml; respects the same workspace conventions the rest of the ChuMicro tooling uses.


Part of the ChuMicro family — small, focused Python libraries for microcontrollers and laptops. Browse all workbench tools. This is a workbench tool — runs on your laptop, drives the boards over serial.

Install

pip install chumicro-pytest-device

chumicro-deploy (and its pyserial / mpremote deps) come along. Auto-registers via the pytest11 entry point — no pytest_plugins = [...] line in conftest.py needed. Native Windows isn't currently supported (the underlying chumicro-deploy raises WindowsNotSupportedError); WSL2 works.

Quick example

A functional test reads like a normal unit test — it just runs on the board:

# libraries/timing/functional_tests/test_heartbeat.py
import time
from chumicro_timing import Heartbeat
from chumicro_timing.ticks import ticks_ms


def test_heartbeat_fires_on_real_clock() -> None:
    heartbeat = Heartbeat(period_ms=10)
    deadline = time.monotonic() + 1.0
    fires = 0
    while time.monotonic() < deadline:
        if heartbeat.poll(ticks_ms()):
            fires += 1
    assert fires > 50

Run on every device targeted by your devices.yml defaults:

pytest libraries/timing/functional_tests --runtime both

The plugin discovers the board, stages chumicro_timing/src/ + the test, executes on-device, parses the on-device pytest result back, and reports PASS / FAIL through host-side pytest.

What's included

Plugin modules

Module Purpose
chumicro_pytest_device.plugin The pytest plugin entry-point module — collection interception, deploy orchestration, result reporting
chumicro_pytest_device.result_parser Parses on-device test output back into TestResult objects
chumicro_pytest_device.pr_summary Renders a markdown PR-summary block from captured run results — drop into a CI step

Pytest options

Option Effect
--runtime {micropython,circuitpython,both} Override defaults.ide_runtime
--micropython-device <id> Override defaults.micropython
--circuitpython-device <id> Override defaults.circuitpython
--deploy-mode {ram,flash} Override the per-device deploy mode
--pr-summary Append a markdown summary block to stdout at end of session
--pr-summary-command <text> The command that re-runs the failed tests, included in the summary

Where this fits

Depends on chumicro-deploy for staging tests on a board. Auto-registers via pytest11; reads devices.yml written by chumicro-workspace.

Companions

Workbench tool Why you'd use it alongside
chumicro-deploy The transport layer the plugin uses for staging. Useful directly when you want to drive a board outside of pytest
chumicro-repl Tail a board's REPL after a deploy — handy for follow-up debugging when a functional test surprises you
chumicro-workspace The host CLI for project workspaces. Reads the same devices.yml schema

Contributing

Working on chumicro-pytest-device itself? Clone the mono-repo if you haven't already — the rest of the workflow assumes you're inside that workspace.

pip install -e .[test]
pytest tests/                  # host-side tests

No hardware-side functional tests for this package itself — its job is to drive consumer libraries' functional tests via pytest libraries/<name>/functional_tests/ against a board registered in devices.yml.

Find this library

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chumicro_pytest_device-0.17.8.tar.gz (61.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chumicro_pytest_device-0.17.8-py3-none-any.whl (72.4 kB view details)

Uploaded Python 3

File details

Details for the file chumicro_pytest_device-0.17.8.tar.gz.

File metadata

  • Download URL: chumicro_pytest_device-0.17.8.tar.gz
  • Upload date:
  • Size: 61.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for chumicro_pytest_device-0.17.8.tar.gz
Algorithm Hash digest
SHA256 a2854c40761dce9fac16d7fc1e0961b4c7d46df22161d3621d9ea6d054ecaa55
MD5 959e25639962abc61aa161801b060c24
BLAKE2b-256 99e5c45f45effbb3e71357d1d5b996097ee86d8980a708e29ce077a491079aa8

See more details on using hashes here.

Provenance

The following attestation bundles were made for chumicro_pytest_device-0.17.8.tar.gz:

Publisher: promote.yml on ChuMicro/ChuMicro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chumicro_pytest_device-0.17.8-py3-none-any.whl.

File metadata

File hashes

Hashes for chumicro_pytest_device-0.17.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5ffd04c60da008ceb5f8d1a96461c5ea9adb61f34cb7884421ba866a2fb968e4
MD5 67479b9983526b4ea4736a946d542bbf
BLAKE2b-256 067f35c45ce58b6dcdd0e5f41c73a4de264d0a8e29184cc8c91608d021d7a6c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for chumicro_pytest_device-0.17.8-py3-none-any.whl:

Publisher: promote.yml on ChuMicro/ChuMicro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.18.0

2 files

0.17.9

2 files

This release

0.17.8 This release

2 files

0.17.7

2 files

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