pytest-embedded-serial-esp is a pytest plugin that extends the pytest-embedded framework to work specifically with Espressif target boards via serial communication. As part of the broader pytest-embedded ecosystem, it enables automated testing, flashing, and interaction with ESP32, ESP8266, and other Espressif SoCs. The library is actively maintained by Espressif Systems, with version 2.7.0 being the latest, and undergoes frequent updates, often including new features and bug fixes.
pip install pytest-embedded-serial-espVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a basic test using `pytest-embedded-serial-esp` to communicate with an Espressif target. The `@pytest.mark.parametrize('embedded_services', ['serial', 'esp'], indirect=True)` decorator is crucial to activate the necessary services for serial communication and Espressif-specific features, including auto-flashing by esptool. The `dut: Dut` fixture provides the interface to interact with the device under test, primarily using `expect_exact()` to wait for specific serial output. Ensure an Espressif device with appropriate firmware (e.g., a 'Hello World' example) is connected via serial.
Upgrade your Python environment to 3.10 or newer.
Update `esptool` to the specified version. Replace `dut.stub` with `dut.esp`. Remove `EsptoolArgs` class usage and the deprecated parameters from `use_esptool()`.
For literal matches, use `dut.expect_exact()`. If using `dut.expect()` with literal strings that might contain regex special characters, escape them or use `re.escape()`.
If `dut.write()` is critical, ensure your target's ESP-IDF console output is configured for UART. Otherwise, rely on `dut.expect()` for output validation.
Run `python -m pip install -U pip` to upgrade pip, then `python -m pip install wheel` to install the wheel package.
On Ubuntu/Debian, install with `sudo apt-get install libdbus-glib-1-dev` or `sudo apt-get install libdbus-1-dev`. For other distributions, consult their package manager.
Replace `dut.stub` with `dut.esp` in your test code.
Remove the `no_stub` parameter from your `use_esptool()` decorator calls.