Skip to content

pytest-embedded Documentation Status Python 3.7+

A pytest plugin that has multiple services available for various functionalities. Designed for the embedded testing.


All packages are published to PyPI. Please install them via pip.

pytest-embedded pytest-embedded-serial pytest-embedded-serial-esp pytest-embedded-idf pytest-embedded-qemu pytest-embedded-arduino

Quick Example

  • pip install pytest-embedded
  • Create a file
from pytest_embedded import Dut

def test_basic_expect(redirect, dut: Dut):
    with redirect():
        print('this would be redirected')

  • Run the test with pytest, the result would be like:
collected 1 item .                                                        [100%]

============================= 1 passed in 0.01s =============================
  • if run with pytest -s, would get output like:
collected 1 item                                                                                           2022-01-01 12:34:56 this would be redirected

============================= 1 passed in 0.01s =============================

The print line is also duplicated to console output.

Extra Services

You can activate more services with pytest --embedded-services service[, service] to enable extra fixtures and functionalities. These services are provided by several optional dependencies. You can install them via pip as well.

Available services:

  • serial: serial port utilities.
  • esp: auto-detect target/port by esptool.
  • idf: auto-detect more app info with ESP-IDF specific rules, auto-flash the binary into the target.
  • jtag: openocd/gdb utilities
  • qemu: running test cases on QEMU instead of the real target.
  • arduino: auto-detect more app info with arduino specific rules, auto-flash the binary into the target.



These packages are still under development, there will be breaking changes between minor version updates.

After the packages released (1.0.0), the versions would follow the semantic versioning rules.