Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pytest-embedded-arduino/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python",
"Topic :: Software Development :: Testing",
]
Expand Down
1 change: 1 addition & 0 deletions pytest-embedded-idf/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python",
"Topic :: Software Development :: Testing",
]
Expand Down
1 change: 1 addition & 0 deletions pytest-embedded-jtag/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python",
"Topic :: Software Development :: Testing",
]
Expand Down
1 change: 1 addition & 0 deletions pytest-embedded-nuttx/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python",
"Topic :: Software Development :: Testing",
]
Expand Down
1 change: 1 addition & 0 deletions pytest-embedded-qemu/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python",
"Topic :: Software Development :: Testing",
]
Expand Down
1 change: 1 addition & 0 deletions pytest-embedded-serial-esp/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python",
"Topic :: Software Development :: Testing",
]
Expand Down
1 change: 1 addition & 0 deletions pytest-embedded-serial/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python",
"Topic :: Software Development :: Testing",
]
Expand Down
3 changes: 2 additions & 1 deletion pytest-embedded-wokwi/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python",
"Topic :: Software Development :: Testing",
]
Expand All @@ -31,7 +32,7 @@ requires-python = ">=3.10"

dependencies = [
"pytest-embedded~=2.6.0",
"wokwi-client>=0.2.0",
"wokwi-client>=0.4.0",
]

[project.optional-dependencies]
Expand Down
7 changes: 2 additions & 5 deletions pytest-embedded-wokwi/pytest_embedded_wokwi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
"""Make pytest-embedded plugin work with the Wokwi CLI."""

WOKWI_CLI_MINIMUM_VERSION = '0.10.1'

from .dut import WokwiDut # noqa
from .wokwi import Wokwi # noqa
from .dut import WokwiDut
from .wokwi import Wokwi

__all__ = [
'WOKWI_CLI_MINIMUM_VERSION',
'Wokwi',
'WokwiDut',
]
Expand Down
30 changes: 9 additions & 21 deletions pytest-embedded-wokwi/pytest_embedded_wokwi/wokwi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
import typing as t
from pathlib import Path

from packaging.version import Version
from pytest_embedded.log import DuplicateStdoutPopen, MessageQueue
from pytest_embedded.utils import Meta
from wokwi_client import GET_TOKEN_URL, WokwiClientSync

from pytest_embedded_wokwi import WOKWI_CLI_MINIMUM_VERSION

from .idf import IDFFirmwareResolver

if t.TYPE_CHECKING: # pragma: no cover
Expand Down Expand Up @@ -61,24 +58,14 @@ def __init__(
# Initialize synchronous Wokwi client
self.client = WokwiClientSync(token)

# Check version compatibility
if Version(self.client.version) < Version(WOKWI_CLI_MINIMUM_VERSION):
logging.warning(
'Wokwi client version %s < required %s (compatibility not guaranteed)',
self.client.version,
WOKWI_CLI_MINIMUM_VERSION,
)
logging.info('Wokwi client library version: %s', self.client.version)

# Prepare diagram file if not supplied
if wokwi_diagram is None:
self.create_diagram_json()
wokwi_diagram = os.path.join(self.app.app_path, 'diagram.json')

# Connect and start simulation
try:
flasher_args = firmware_resolver.resolve_firmware(app)
firmware_path = Path(flasher_args).as_posix()
firmware_path = Path(firmware_resolver.resolve_firmware(app)).as_posix()
elf_path = Path(app.elf_file).as_posix()

self._setup_simulation(wokwi_diagram, firmware_path, elf_path)
Expand All @@ -93,16 +80,17 @@ def _setup_simulation(self, diagram: str, firmware_path: str, elf_path: str):
logging.info('Connected to Wokwi Simulator, server version: %s', hello.get('version', 'unknown'))

# Upload files
self.client.upload_file('diagram.json', diagram)
firmware = self.client.upload_file('pytest.bin', firmware_path)

self.client.upload_file('pytest.elf', elf_path)
self.client.upload_file('diagram.json', Path(diagram))
self.client.upload_file('pytest.elf', Path(elf_path))
if firmware_path.endswith('flasher_args.json'):
firmware = self.client.upload_idf_firmware(firmware_path)
self.client.start_simulation(firmware.firmware, elf='pytest.elf')
else:
firmware = self.client.upload_file('pytest.bin', Path(firmware_path))
self.client.start_simulation(firmware, elf='pytest.elf')

logging.info('Uploaded diagram and firmware to Wokwi. Starting simulation...')

# Start simulation
self.client.start_simulation(firmware, elf='pytest.elf')

def _start_serial_monitoring(self):
"""Start monitoring serial output and forward to stdout and message queue."""

Expand Down
1 change: 1 addition & 0 deletions pytest-embedded/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python",
"Topic :: Software Development :: Testing",
]
Expand Down