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 (new) 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
For development the following are also needed:
- tox
- pytest-mock
- pre-commit
- isort
- flake8
- codespell
- black
You can install "pytest-libiio" via pip from PyPI:
$ pip install pytest-libiio
This plugin is used to make the access of libiio contexts easier and to provide a unified API through fixtures.
Get list of context descriptions of all found contained
import pytest
import iio
def test_libiio_device(context_desc):
hardware = ["pluto", "adrv9361", "fmcomms2"]
for ctx_desc in context_desc:
if ctx_desc["hw"] in hardware:
ctx = iio.Context(ctx_desc["uri"])
if not ctx:
pytest.skip("No required hardware found")
Require certain hardware through marks
import pytest
import iio
@pytest.mark.iio_hardware("adrv9361")
def test_libiio_device(context_desc):
for ctx_desc in context_desc:
ctx = iio.Context(ctx_desc["uri"])
...
Mock testing is common with libiio's python library since hardware is needed otherwise. In future releases we hope to extend features in pytest-mock through this plugin to make mocking libiio more streamlined.
Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit 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.