A test has typically additional dependencies, like the path to an
executable, the path to a capture file, a configuration directory, the
availability of an optional library, and so on. The Python unittest
library is quite limited in expressing test dependencies, these are
typically specified on the class instance itself (
self) or via globals
pytest is a better test framework which has full parallelization support (test-level instead of just suite-level), provides nicer test reports, and allows modular fixtures. Ideally the test suite should fully switch to pytest, but in meantime a compatibility layer is provided via the “fixtures” module.
A fixture is a function decorated with
@fixtures.fixture and can
fixtures.skip("reason") to skip tests that depend on the
fixture, or return/yield a value.
Test functions (and other fixture functions) can receive the fixture
value by using the name of the fixture function as function parameters.
Common fixtures are available in
fixtures_ws.py and includes
cmd_tshark for the path to the
tshark executable and
for a factory function that produces the path to a capture file.
Each unittest test case must be decorated with
@fixtures.uses_fixtures to ensure that unittest test classes can
actually request fixture dependencies.