A pytest plugin to manage interfacing with libiio contexts
pytest-libiio is pytest plugin to manage interfacing with libiio contexts. This plugin is handy for leveraging the zeroconf features of libiio to find, filter, and map libiio contexts to tests. It was created for pyadi-iio testing but is used in other applications that need an organized way to handle libiio contexts without hardcoding URIs or lots of boilerplate code.
- libiio and pylibiio
- pytest
- pyyaml
Optional for emulation support:
Optional for SSH telemetry collection:
- paramiko (or install with
pip install pytest-libiio[ssh])
For development the following are also needed:
- nox
- pytest-mock
- pre-commit
- ruff
You can install "pytest-libiio" via pip from PyPI:
$ pip install pytest-libiio
The plugin exposes three pytest fixtures — iio_uri, single_ctx_desc,
and context_desc — plus an iio_hardware marker that filters tests by
detected hardware. The full reference and scenario walkthroughs (emulation,
attribute coverage, telemetry, xdist) live in the
hosted documentation.
Quickstart — get a URI for a marked board and open the context:
import iio
import pytest
@pytest.mark.iio_hardware("pluto")
def test_pluto(iio_uri):
ctx = iio.Context(iio_uri)
assert ctx.find_device("ad9361-phy") is not NoneFan out across every matching board with context_desc:
import iio
import pytest
@pytest.mark.iio_hardware(["pluto", "adrv9361", "fmcomms2"])
def test_all_matching_boards(context_desc):
for ctx_desc in context_desc:
ctx = iio.Context(ctx_desc["uri"])
...Run against the bundled ADI hardware map so the marker names resolve:
pytest --adi-hw-mapContributions are very welcome. Tests run via nox (nox -s tests);
please ensure coverage at least stays the same before submitting a pull
request.
Distributed under the terms of the BSD-3 license, "pytest-libiio" is free and open source software
If you encounter any problems, please file an issue along with a detailed description.