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

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.0
File Size Uploaded Provenance Actions
pytest_embedded_wokwi-2.10.0.tar.gz 11.2 kB Without provenance Details for pytest_embedded_wokwi-2.10.0.tar.gz

Built distribution (wheel)

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

Total release size: 21.1 kB

Release files / pytest_embedded_wokwi-2.10.0.tar.gz

Download URL pytest_embedded_wokwi-2.10.0.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
08ad6de9c6d40a20fbce171587c35eceb4d42f8a85f3eb7b3d39f982ffc0aff6
BLAKE2b-256 checksum
How to use checksums
894a1bde3d70b2377e4710268210c3fa7b6c583f1d2810c02fe04befd6c6edcb
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.0-py3-none-any.whl

Download URL pytest_embedded_wokwi-2.10.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4dfdef808c716d091b315775dff3ae20c227df71a6f89e1a1e0106ed6fb7c39
BLAKE2b-256 checksum
How to use checksums
e4c750f236e24bc0a81ec669c8cd947b2eb1bd36dfc84656d59fdb7440bea411
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.0

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