Skip to content

tfcollins/pytest-libiio

Repository files navigation

pytest-libiio

PyPI version Python versions See Build Status on GitHub Actions See Coverage Status on Coveralls Documentation Build Status

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.

Requirements

  • 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

Installation

You can install "pytest-libiio" via pip from PyPI:

$ pip install pytest-libiio

Usage

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 None

Fan 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-map

Contributing

Contributions are very welcome. Tests run via nox (nox -s tests); please ensure coverage at least stays the same before submitting a pull request.

License

Distributed under the terms of the BSD-3 license, "pytest-libiio" is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

About

pytest plugin for working with libiio contexts

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages