qnet.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:

QnetAsciiTestPrinter 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 qnet.utils.testing.QnetAsciiTestPrinter(cache=None, settings=None)[source]

Bases: qnet.printing.asciiprinter.QnetAsciiPrinter

A Printer subclass for testing

qnet.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 qnet.utils.testing
>>> datadir = pytest.fixture(qnet.utils.testing.datadir)
qnet.utils.testing.check_idempotent_create(expr)[source]

Check that an expression is ‘idempotent’