Skip to main content

A pytest plugin for testing libiio based devices

Project description

PyPI version Python versions See Build Status on Travis CI See Coverage Status on Coveralls Documentation 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 (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.

Requirements

  • libiio and pylibiio

  • pytest

  • pyyaml

For development the following are also needed:

  • tox

  • pytest-mock

  • pre-commit

  • isort

  • flake8

  • codespell

  • black

Installation

You can install “pytest-libiio” via pip from PyPI:

$ pip install pytest-libiio

Usage

This plugin is used to make the access of libiio contexts easier and to provide a unified API through fixtures.

Accessing contexts

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"])
        ...

Future ideas

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.

Contributing

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.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_libiio-0.0.27.tar.gz (96.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_libiio-0.0.27-py3-none-any.whl (110.0 kB view details)

Uploaded Python 3

File details

Details for the file pytest_libiio-0.0.27.tar.gz.

File metadata

  • Download URL: pytest_libiio-0.0.27.tar.gz
  • Upload date:
  • Size: 96.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for pytest_libiio-0.0.27.tar.gz
Algorithm Hash digest
SHA256 978759173b5a6ccd8cc9d043dd19775782e3e8a8211541fe11e2a204dc4f8650
MD5 65b7551c140fdfba348c99f05a08799d
BLAKE2b-256 caac3d052d1db27ee34aaab61402ec2890021db8be9a4fe26fe7d552be27ab88

See more details on using hashes here.

File details

Details for the file pytest_libiio-0.0.27-py3-none-any.whl.

File metadata

  • Download URL: pytest_libiio-0.0.27-py3-none-any.whl
  • Upload date:
  • Size: 110.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for pytest_libiio-0.0.27-py3-none-any.whl
Algorithm Hash digest
SHA256 ebc7a784bdf95846e8ca0d72439d4b469502135e1dcda67edbebbc63ea14ad32
MD5 c1bc59b82574672b3c172bf5b084d16b
BLAKE2b-256 51fa5397f666e03fc3fb105613ad4cd9abe38412f1149de05bd23541745c2e74

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page