openocd-python/tests/conftest.py
Ryan Malloy 7e1eac5e2d Add openocd-python: typed async-first Python bindings for OpenOCD
Standalone PyPI package providing structured access to the full OpenOCD
command surface via the TCL RPC protocol (port 6666). Async-first API
with sync wrappers for every method.

Subsystems: target control, memory read/write, CPU registers, flash
programming, JTAG chain/scan/boundary, breakpoints/watchpoints, SVD
peripheral decoding, RTT channels, transport/adapter config.

79 tests passing against a mock TCL RPC server.
2026-02-12 17:55:58 -07:00

38 lines
1012 B
Python

"""Shared pytest fixtures for openocd-python tests."""
from __future__ import annotations
import pytest
from openocd.connection.tcl_rpc import TclRpcConnection
from openocd.session import Session
from tests.mock_server import MockOpenOCDServer
@pytest.fixture
async def mock_ocd():
"""Start a MockOpenOCDServer, yield (host, port), stop on teardown."""
server = MockOpenOCDServer()
await server.start()
host, port = server.address
yield host, port, server
await server.stop()
@pytest.fixture
async def connection(mock_ocd):
"""A TclRpcConnection connected to the mock server."""
host, port, _server = mock_ocd
conn = TclRpcConnection(timeout=5.0)
await conn.connect(host, port)
yield conn
await conn.close()
@pytest.fixture
async def session(mock_ocd):
"""A Session connected to the mock server via Session.connect()."""
host, port, _server = mock_ocd
sess = await Session.connect(host, port, timeout=5.0)
yield sess
await sess.close()