Back to blog
November 25, 2026
12 min read
Instrument Automation

OpenHTF vs pytest for Hardware Testing in 2026 (Free, Code Inside)

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 vs pytest for Hardware Testing in 2026 (Free, Code Inside)

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 vs pytest at a glance

OpenHTFpytest
Built forHardware testing, bench to manufacturing floorSoftware testing, adapted for hardware
Latest release (PyPI)1.6.3, October 8, 20269.2.0, October 27, 2026
LicenseApache-2.0MIT
Python3.10 or newer3.10 or newer
Test unitPhase: a Python callable with metadataTest function
Hardware accessPlugs, with tearDownFixtures, with yield teardown
LimitsDeclared on the measurement, with unitsIn an assert, in code
Run outcomesPASS, FAIL, ERROR, TIMEOUT, ABORTEDpassed, failed, error, skipped, xfail
Operator flowDUT ID prompt, station server, web GUINone built in
OutputTest record via callbacks: JSON, console, MfgInspectorTerminal, JUnit XML, HTML via plugin
EcosystemSmall, a handful of bundled plugs2,180 plugins on pytest's plugin list
GitHub stars (Nov 25, 2026)73214,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.

How OpenHTF models a hardware test

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:

  1. 1

    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.

  2. 2

    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.

  3. 3

    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.

  4. 4

    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.

How pytest handles a hardware test

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:

  1. 1

    Fixtures hold an instrument session, with scope="session" to open it once and a yield for teardown.

  2. 2

    Parametrization turns one test into a matrix of set points.

  3. 3

    `record_property` attaches a value to the test case in the JUnit XML report, which is how a measured number survives the run.

  4. 4

    `--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.40

It 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.

The pytest plugins that close the gap

These are the plugins hardware teams reach for, with versions and licenses from PyPI on November 25, 2026:

PluginVersionLicenseWhat it adds
pytest-html4.2.0MPL-2.0An HTML report per run
pytest-xdist3.8.0MITDistributed runs across CPUs
pytest-rerunfailures16.7MPL-2.0Re-runs failed tests
pytest-check3.1.0MITMultiple 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.

Measurements, limits, and the record each run leaves

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.

Retries, timeouts, and failure handling

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.

Operator flow and station deployment

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.

When to pick OpenHTF and when to pick pytest

Your situationPick
Technician runs the station, needs a DUT ID promptOpenHTF
Every value must be stored with its limits and unitsOpenHTF
Results must be loaded into a database laterOpenHTF, via a custom output callback
Engineer-run validation and characterizationpytest
Hardware-in-the-loop checks in CIpytest
Existing pytest suite you do not want to rewritepytest, plus HardPy or pytest-check
Many set points, quick sweepspytest parametrization
Team needs answers on Stack Overflow by Fridaypytest

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.

Using both in one repository

The pairing that holds up in practice:

  • •pytest for the code. Unit-test every plug and driver in CI against a simulated instrument. PyVISA's simulated backend, pyvisa-sim, is built for this.
  • •OpenHTF for the station. The same plug classes run on hardware, with measurements, limits, and the operator prompt.
  • •One results store. Point OpenHTF's JSON output, or both runners through TofuPilot, at one place so validation and production data share a serial number.

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.

Where TestFlow fits next to OpenHTF and pytest

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.

  • •Authoring. The agent builds the workflow and the instrument code for your models, which you review before anything energizes the bench. The supported instruments page lists the catalog.
  • •Python you keep. A workflow exports as a standalone Python package with one entry point that runs without TestFlow, so it can sit in the same repository as your OpenHTF plugs or pytest suite.
  • •TestStand import. Teams moving off NI can import TestStand sequences with the sequences and calls preserved.

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.

Where TestFlow fits

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.

  1. 1

    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.

  2. 2

    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."

  3. 3

    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.

  4. 4

    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 TestFlow builder: a one-line test request on the left, the generated instrument workflow in the centre, and the live run with its streaming SCPI execution log on the right.
The TestFlow agent turning a one-line test request into a runnable workflow, then running it on the bench. Click to enlarge.
  • Vendor-neutral by design. One workflow drives Keysight, Tektronix, Rohde & Schwarz, Rigol, Keithley, Anritsu, and any other SCPI instrument over standard VISA.
  • Built in the browser, run on the bench. Workflows live in your workspace, so a sequence built in one lab runs the same way in another. Bench runs use the Windows desktop app.
  • Free version to start. Sign in at app.testflowinc.com and build your first workflow today; teams can book a demo to scope a Bench Pilot.
Instrument vendors TestFlow drives over VISA and SCPI: Keysight, Tektronix, Rohde & Schwarz, NI, Keithley, Agilent, Anritsu, Siglent, Chroma, Fluke, Yokogawa, Kikusui, TDK-Lambda, ESPEC, Watlow, Pickering, Copper Mountain, inTEST, Thermonics, and Microchip
Works with the instruments already on your bench. Full list on the supported instruments page.

The step-by-step walkthrough, VISA address formats, and Test Planner prompts are all in the TestFlow product guide.

Frequently asked questions

Is OpenHTF better than pytest for hardware testing?

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.

Is OpenHTF still maintained in 2026?

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.

Can pytest record measurements with limits?

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.

Does OpenHTF have an operator interface?

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.

Can I use OpenHTF and pytest together?

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.

Where does TestFlow fit for a team choosing between OpenHTF and pytest?

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.

TestFlow

Automate every instrument in the lab,
Create test workflows in minutes

  1. 01Describe the testIn a sentence, the way you would tell a colleague.
  2. 02The agent builds itWorkflow and script for your instruments, any vendor.
  3. 03Run it, get the reportOn your bench, with the measured values.

Tags

openhtf vs pytestpytest hardware testingopenhtfpytest for hardwarepython hardware test frameworkopenhtf tutorialpytest production test
Share this article:
Ali Kamaly

Article by

Ali Kamaly

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.

Your next test, automated today

Describe the test. TestFlow builds the workflow, runs it on your instruments, and writes the report. See it on a bench like yours.