The purpose of the test fixtures is to ease the writing of test functions by providing information and data automatically. You may find more documentation on fixture in its official documentation. We describe here the fixtures defined in . Some of them are used in the default test module, see builtin-test-module
.
The :pyrunner
fixture is used to execute the passed with --exe-runner
. This fixture is an :pyobject
<pytest_executable.script_runner.ScriptRunner>
which can execute the script with the :pyrun
method. This method returns the exit status of the script execution. The value of the exit status shall be 0 when the execution is successful.
When --exe-runner
is not set, a function that uses this fixture will be skipped.
The :pyoutput_path
fixture provides the absolute path to the output directory of a test case as a Path object.
The :pyregression_file_path
fixture provides the paths to the reference data of a test case. A test function that use this fixture is called once per reference item (file or directory) declared in the yaml-ref
of a (thanks to the parametrize feature). The :pyregression_file_path
object has the attributes:
- :py
relative
: a Path object that contains the path to a reference item relatively to the output directory of the test case. - :py
absolute
: a Path object that contains the absolute path to a reference item.
If --exe-regression-root
is not set then a test function that uses the fixture is skipped.
You may use this fixture with the fixture-output_path
to get the path to an output file that shall be compared to a reference file.
For instance, if a under inputs/case
contains:
references:
- output/file
- '**/*.txt'
and if --exe-regression-root
is set to a directory references
that contains:
references
└── case
├── 0.txt
└── output
├── a.txt
└── file
then a test function that uses the fixture will be called once per item of the following list:
[
"references/case/output/file",
"references/case/0.txt",
"references/case/output/a.txt",
]
and for each these items, the :pyregression_file_path
is set as described above with the relative and absolute paths.
The :pytolerances
fixture provides the contents of the yaml-tol
of a as a dictionary that maps names to :pyTolerances
<pytest_executable.settings.Tolerances>
objects.
For instance, if a contains:
tolerances:
data-name1:
abs: 1.
data-name2:
rel: 0.
abs: 0.
then the fixture object is such that:
tolerances["data-name1"].abs = 1.
tolerances["data-name1"].rel = 0.
tolerances["data-name2"].abs = 0.
tolerances["data-name2"].rel = 0.