qalgebra.utils.testing module

Collection of routines needed for testing. This includes proto-fixtures, i.e. routines that should be imported and then turned into a fixture with the pytest.fixture decorator.

See <https://pytest.org/latest/fixture.html>

Summary

Classes:

QalgebraAsciiTestPrinter

A Printer subclass for testing

Functions:

check_idempotent_create

Check that an expression is ‘idempotent’

datadir

Proto-fixture responsible for searching a folder with the same name of test module and, if available, moving all contents to a temporary directory so tests can use them freely.

Reference

class qalgebra.utils.testing.QalgebraAsciiTestPrinter(cache=None, settings=None)[source]

Bases: qalgebra.printing.asciiprinter.QalgebraAsciiPrinter

A Printer subclass for testing

qalgebra.utils.testing.datadir(tmpdir, request)[source]

Proto-fixture responsible for searching a folder with the same name of test module and, if available, moving all contents to a temporary directory so tests can use them freely.

In any test, import the datadir routine and turn it into a fixture:

>>> import pytest
>>> import qalgebra.utils.testing
>>> datadir = pytest.fixture(qalgebra.utils.testing.datadir)
qalgebra.utils.testing.check_idempotent_create(expr)[source]

Check that an expression is ‘idempotent’