Skip to main content

pytest-embedded-wokwi

pytest-embedded service for running tests on Wokwi instead of the real target.

Wokwi supports most ESP32 targets, including: esp32, esp32s2, esp32s3, esp32c3, esp32c6, and esp32h2. In addition, it supports a wide range of peripherals, including sensors, displays, motors, and debugging tools.

Running the tests with Wokwi requires an internet connection. Your firmware is uploaded to the Wokwi server for the duration of the simulation, but it is not saved on the server. On-premises Wokwi installations are available for enterprise customers.

Wokwi API Tokens

Before using this plugin, you need to create a free Wokwi account and generate an API key. You can then set the WOKWI_CLI_TOKEN environment variable to the API key.

Linux / Mac OS / WSL:

export WOKWI_CLI_TOKEN="your-api-key"

Windows PowerShell:

$env:WOKWI_CLI_TOKEN="your-api-key"

Usage

To run your tests with Wokwi, make sure to specify the wokwi service when running pytest, e.g.:

pytest --embedded-services idf,wokwi

USB Serial JTAG

By default, Wokwi diagrams use UART connections ($serialMonitor:TX/$serialMonitor:RX) for serial communication. Some targets (e.g. ESP32-P4) can use USB Serial JTAG instead. You can enable this with the --wokwi-usb-serial-jtag flag:

pytest --embedded-services idf,wokwi --wokwi-usb-serial-jtag true

This works for both auto-generated diagrams and diagrams loaded from disk (including those specified via --wokwi-diagram). When enabled, the flag will:

  • Set the serialInterface attribute to USB_SERIAL_JTAG on the board part
  • Remove any $serialMonitor connections from the diagram

Writing Tests

When writing tests for your firmware, you can use the same pytest fixtures and assertions as you would for local testing. The main difference is that your tests will be executed in the Wokwi simulation environment and you have access to the Wokwi API for controlling the simulation through the wokwi fixture.

All interactions with the Wokwi simulation is through the wokwi.client - wokwi-python-client

For example, you can use wokwi.client.set_control() to control virtual components in the simulation, such as buttons, LEDs, and other peripherals. Whole documentations can be found at Wokwi Documentation

Quick Example: Button Test

import logging
from pytest_embedded import Dut
from pytest_embedded_wokwi import Wokwi


def test_gpio(dut: Dut, wokwi: Wokwi):
    logger = logging.getLogger(__name__)

    logger.info('Waiting for Button test begin...')
    dut.expect_exact('Button test')

    for i in range(3):
        logger.info(f'Setting button pressed for {i + 1} seconds')
        wokwi.client.set_control('btn1', 'pressed', 1)

        dut.expect_exact(f'Button pressed {i + 1} times')
        wokwi.client.set_control('btn1', 'pressed', 0)

Metadata

Release files for pytest-embedded-wokwi 2.10.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-embedded-wokwi 2.10.1
File Size Uploaded Provenance Actions
pytest_embedded_wokwi-2.10.1.tar.gz 11.2 kB Without provenance Details for pytest_embedded_wokwi-2.10.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-embedded-wokwi 2.10.1
File Interpreter ABI Platform Actions
pytest_embedded_wokwi-2.10.1-py3-none-any.whl Python 3 none any Details for pytest_embedded_wokwi-2.10.1-py3-none-any.whl

Total release size: 21.2 kB

Release files / pytest_embedded_wokwi-2.10.1.tar.gz

Download URL pytest_embedded_wokwi-2.10.1.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1b74f72367c71291d225cb947d1a693138d0f450f1dd507142c8e4b94d6092eb
BLAKE2b-256 checksum
How to use checksums
babebb0967e4683e56d4d9b37cba928e463f16c3c91a41ba07022d27319a30ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Release files / pytest_embedded_wokwi-2.10.1-py3-none-any.whl

Download URL pytest_embedded_wokwi-2.10.1-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f1b62de43fd31da7235650182055da540de3f31a50e74198cabcc8237ee61fd
BLAKE2b-256 checksum
How to use checksums
3ccdde74ba9ca2603b1d7a747fbcec6965c65222021e485f8f3861c0d9009eec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Security for pytest-embedded-wokwi 2.10.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.10.1 This release

2 release files No provenance

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