OpenHTF and pytest both run Python hardware tests for free. One was built for test stations, the other for software, and the difference shows up in limits, operator prompts, and the record each run leaves behind. Checked against both repositories in November 2026.

OpenHTF is a Python framework built for hardware test stations, and pytest is a general Python test runner that engineers adapt for hardware; for a production station that records measurements with limits and prompts an operator, OpenHTF fits better, and for engineer-run validation, CI, and characterization, pytest fits better. Both are free. OpenHTF 1.6.3 (Apache-2.0) shipped on October 8, 2026, and pytest 9.2.0 (MIT) shipped on October 27, 2026, both requiring Python 3.10 or newer. The real difference is the data model: OpenHTF stores a named measurement with units and a validator for every value, while pytest stores a pass or a fail.
This comparison is for engineers choosing a Python framework for a validation bench or a production station, often after leaving LabVIEW or NI TestStand. Every version, license, and feature below was checked against the project's own repository or PyPI page on November 25, 2026. For the wider landscape, including HardPy, TofuPilot, OpenTAP, and Robot Framework, see Python hardware test frameworks, and for the instrument layer underneath both, see the Python instrument control hub.
| OpenHTF | pytest | |
|---|---|---|
| Built for | Hardware testing, bench to manufacturing floor | Software testing, adapted for hardware |
| Latest release (PyPI) | 1.6.3, October 8, 2026 | 9.2.0, October 27, 2026 |
| License | Apache-2.0 | MIT |
| Python | 3.10 or newer | 3.10 or newer |
| Test unit | Phase: a Python callable with metadata | Test function |
| Hardware access | Plugs, with tearDown | Fixtures, with yield teardown |
| Limits | Declared on the measurement, with units | In an assert, in code |
| Run outcomes | PASS, FAIL, ERROR, TIMEOUT, ABORTED | passed, failed, error, skipped, xfail |
| Operator flow | DUT ID prompt, station server, web GUI | None built in |
| Output | Test record via callbacks: JSON, console, MfgInspector | Terminal, JUnit XML, HTML via plugin |
| Ecosystem | Small, a handful of bundled plugs | 2,180 plugins on pytest's plugin list |
| GitHub stars (Nov 25, 2026) | 732 | 14,751 |
Neither column wins. OpenHTF wins every row that involves a technician or a test record. pytest wins every row that involves an engineer, a CI server, or an ecosystem.
The OpenHTF README describes a test as an ordinary Python program that instantiates Test with phases and calls execute(). OpenHTF then manages setup, execution, and teardown, tracks everything gathered, and produces a pass/fail result. Four ideas carry the framework:
Phases. Plain Python callables, run in order. A phase can return a PhaseResult to steer the run: CONTINUE, FAIL_AND_CONTINUE, REPEAT (bounded by repeat_limit), SKIP, STOP, or FAIL_SUBTEST. Phase options include timeout_s and run_if.
Measurements. Declared with a specification of what passes. If any measurement is out of spec when the run ends, the whole run fails. Validators include in_range and equals, and units come from a UNECE-based table such as units.VOLT.
Plugs. Classes that wrap the DUT or test equipment, with a tearDown method OpenHTF calls at the end. The bundled set is small: user_input, usb, cambrionix, device_wrapping, and generic. Bench instrument plugs are yours to write, usually around PyVISA.
Output callbacks. json_factory, console_summary, and mfg_inspector ship in the repository, and you can write your own.
Here is a complete OpenHTF test for a 3.3 V rail, measured with a SCPI DMM. It uses only APIs exported by openhtf/__init__.py and the bundled user_input plug:
# rail_test.py: python rail_test.py
import pyvisa
import openhtf as htf
from openhtf.output.callbacks import json_factory
from openhtf.plugs import user_input
class Dmm(htf.BasePlug):
"""SCPI DMM over LAN, opened once per test run."""
RESOURCE = "TCPIP0::192.168.1.50::inst0::INSTR"
def __init__(self):
self._rm = pyvisa.ResourceManager()
self._inst = self._rm.open_resource(self.RESOURCE)
self._inst.timeout = 10000
def dc_volts(self) -> float:
return float(self._inst.query("MEAS:VOLT:DC? 10"))
def tearDown(self):
self._inst.close()
@htf.plug(dmm=Dmm)
@htf.measures(
htf.Measurement("rail_3v3").in_range(3.20, 3.40).with_units(htf.units.VOLT)
)
def measure_rail(test, dmm):
test.measurements.rail_3v3 = dmm.dc_volts()
if __name__ == "__main__":
test = htf.Test(measure_rail)
test.add_output_callbacks(json_factory.OutputToJSON("./{dut_id}.rail.json", indent=2))
test.execute(test_start=user_input.prompt_for_test_start())The run prompts for a DUT ID, records rail_3v3 with its limits and unit, and writes one JSON file per unit. That file is the product: a record you can load into a database a year later and still know what the bound was.
pytest models the same test with a fixture and an assert. The pytest repository is MIT licensed, and its documentation's plugin list counted 2,180 plugins on November 25, 2026. Four features do most of the hardware work:
Fixtures hold an instrument session, with scope="session" to open it once and a yield for teardown.
Parametrization turns one test into a matrix of set points.
`record_property` attaches a value to the test case in the JUnit XML report, which is how a measured number survives the run.
`--junit-xml` writes a report that Jenkins, GitLab, and most CI servers read.
The same rail check, in pytest:
# test_rail.py: pytest --junit-xml=rail.xml
import pyvisa
import pytest
@pytest.fixture(scope="session")
def dmm():
rm = pyvisa.ResourceManager()
inst = rm.open_resource("TCPIP0::192.168.1.50::inst0::INSTR")
inst.timeout = 10000
yield inst
inst.close()
@pytest.mark.parametrize("rng", [10, 100])
def test_rail_3v3(dmm, record_property, rng):
volts = float(dmm.query(f"MEAS:VOLT:DC? {rng}"))
record_property("rail_3v3_volts", volts)
assert 3.20 <= volts <= 3.40It is shorter and every Python engineer can read it. What it does not do: the limits live in the assert, there is no unit, there is no DUT ID, and a failed assert stops that test before any later checks in it run.
These are the plugins hardware teams reach for, with versions and licenses from PyPI on November 25, 2026:
| Plugin | Version | License | What it adds |
|---|---|---|---|
| pytest-html | 4.2.0 | MPL-2.0 | An HTML report per run |
| pytest-xdist | 3.8.0 | MIT | Distributed runs across CPUs |
| pytest-rerunfailures | 16.7 | MPL-2.0 | Re-runs failed tests |
| pytest-check | 3.1.0 | MIT | Multiple failures per test, so later checks still run |
On a shared bench, be careful with pytest-xdist: two workers that open the same instrument will interleave SCPI commands. Split work by instrument, or do not parallelize hardware tests at all. If you need an operator panel on top of an existing pytest suite, HardPy is a pytest plugin that adds one, and it is covered with its GPL-3.0 caveat in Python hardware test frameworks.
This is the row that decides most evaluations.
OpenHTF treats the measurement as data. The name, value, unit, validator, and outcome go into the test record, and the run outcome is derived from them. Changing a bound changes one declaration, and the old bound is still visible in old records.
pytest treats the measurement as a side effect. The assert decides pass or fail, and record_property keeps the value, but the bound is not stored next to it unless you store it yourself. For a validation engineer who reads the code, that is fine. For a quality engineer asking why unit 4,812 passed in March, it is a gap.
If your customer or your auditor needs signed reports, the fields a result row must carry are listed in automated test report generation. OpenHTF's record carries most of them by default. pytest needs a plugin or your own schema.
Bench hardware fails in ways software does not: a supply that has not settled, a scope that misses a trigger, a USB instrument that drops off the bus. The two frameworks handle this differently.
OpenHTF puts the decision inside the phase. A phase that returns PhaseResult.REPEAT runs again, ignoring that attempt's measurement outcomes, up to the phase's repeat_limit, after which OpenHTF treats it as a stop. timeout_s bounds a phase in seconds, and a run that exceeds it ends with the TIMEOUT outcome rather than FAIL, which keeps a hung instrument separate from a bad unit in your yield numbers. FAIL_AND_CONTINUE marks the phase failed and moves on, so one bad rail does not hide the next five measurements.
pytest puts the decision in plugins. pytest-rerunfailures re-runs a failed test, and pytest-check lets a test record several failed checks before it ends. Both work, but a rerun is a whole new test, and the JUnit XML shows the retry rather than one record with an attempt count.
OpenHTF has a concept of a station. It writes a breadcrumb for each run, and tests with the same name are treated as the same station, so its web frontend can list stations. The repository ships station_server.py, web_gui_server.py, and dashboard_server.py under openhtf/output/servers, and user_input.prompt_for_test_start() asks the operator for a DUT ID before the first phase.
pytest has no operator concept. A technician would start it from a terminal or a script you write. Teams that need a station UI on pytest add HardPy or a data platform. TofuPilot's documentation lists its own framework, OpenHTF, pytest, and Robot Framework as supported test runners on every plan, which means the choice between OpenHTF and pytest does not lock you out of a hosted dashboard later.
| Your situation | Pick |
|---|---|
| Technician runs the station, needs a DUT ID prompt | OpenHTF |
| Every value must be stored with its limits and units | OpenHTF |
| Results must be loaded into a database later | OpenHTF, via a custom output callback |
| Engineer-run validation and characterization | pytest |
| Hardware-in-the-loop checks in CI | pytest |
| Existing pytest suite you do not want to rewrite | pytest, plus HardPy or pytest-check |
| Many set points, quick sweeps | pytest parametrization |
| Team needs answers on Stack Overflow by Friday | pytest |
Two cautions apply to both. First, neither ships drivers for bench instruments, so you write the SCPI layer on PyVISA or a driver library from Python instrument control libraries compared. Second, neither is a full test executive with user privileges and shipped database schemas. If you need both on day one, read NI TestStand alternatives and the test sequencer comparison before you commit.
The pairing that holds up in practice:
pyvisa-sim, is built for this.If you are migrating off LabVIEW, this split maps cleanly: driver VIs become plugs, and the TestStand sequence becomes an OpenHTF test. LabVIEW to Python migration covers the inventory step, and LabVIEW vs Python covers the decision behind it.
Both frameworks answer how a test runs. Neither answers who writes it. TestFlow is an AI agent for electronics testing: you describe the test, the agent builds the automation, drives the instruments over VISA and SCPI from any vendor, and writes the report from the measured results.
The limits, stated plainly: bench runs need the Windows desktop app, and the web app builds and simulates. TestFlow is not a full test executive, with no operator and user management and no database connectivity. DAQ coverage is narrow: the NI USB-6001, USB-6501, and PCI-6515 through NI-DAQmx. The trade-off against hand-written scripts is laid out in TestFlow vs Python and PyVISA, and there is a free version to start on the pricing page.
TestFlow works one step before either framework. It turns a description of the measurement into a reviewable workflow, runs it on the bench, and writes the report from the measured values.
Connect your instruments. Pick the manufacturer and model, paste the VISA address (USB, LAN, GPIB, or serial), and the agent knows what is on your bench. No bench yet? Use a placeholder address, build the full automation, and swap in the real address when you are in the lab.
Tell the agent what to test. For example, "run a VI sweep from 1 to 10 V in 1 V steps at 0.5 A load current," or "suggest the tests for a power-management device."
The agent builds the complete workflow in seconds. Instrument-aware automation appears on the canvas, with the generated scripts visible in a code panel you can inspect and edit.
Run it in your lab. Click Run in the TestFlow desktop app for Windows and the status panel streams results step by step, with measured values inline (VOUT = 3.301 V, asserted 3.2 to 3.4 V, PASS). One click exports a structured PDF report, or the raw results as CSV.


The step-by-step walkthrough, VISA address formats, and Test Planner prompts are all in the TestFlow product guide.
For manufacturing stations, usually yes. OpenHTF records named measurements with limits and units, prompts the operator for a DUT ID, and writes a structured test record per run. pytest is better for engineer-run validation and CI, where its fixtures, parametrization, 2,180 listed plugins, and JUnit XML output matter more than an operator flow.
Yes. OpenHTF 1.6.3 was published to PyPI on October 8, 2026, and the google/openhtf repository received commits in late November 2026. It is Apache-2.0 licensed, requires Python 3.10 or newer, and its README states that it is not an official Google product.
Not natively. A pytest test passes or fails on an assert. You can attach values to the JUnit XML report with the record_property fixture, keep going after a failed check with the pytest-check plugin, and add an HTML report with pytest-html, but the limit itself lives in your code.
It has a station server and web GUI in openhtf/output/servers, and a user_input plug that prompts the operator for a DUT ID at test start. It is a functional interface for engineers and technicians rather than a branded kiosk, and most production teams customize or wrap it.
Yes, in separate roles. A common split is pytest for driver and plug unit tests in CI, run against a simulated instrument, and OpenHTF for the station test that runs on real hardware. TofuPilot's documentation lists both as supported test runners, so their results can land in the same database.
TestFlow builds the test instead of you writing it. It turns a description into a workflow, runs it on SCPI instruments through a Windows desktop app, writes the report from measured results, and exports a standalone Python package. It is not a full test executive, with no operator and user management or database connectivity.

Article by
Ali Kamaly is the Co-Founder and CEO of TestFlow, an AI-native platform for electronics test automation. He writes about test automation, lab validation, and the infrastructure behind modern hardware engineering.
Describe the test. TestFlow builds the workflow, runs it on your instruments, and writes the report. See it on a bench like yours.