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 pytest fixture in its official documentation. We describe here the fixtures defined in pytest-executable. Some of them are used in the default test module, see Default test module.
runner fixture is used to execute the runner shell script passed with
--exe-runner. This fixture is an
object which can execute the script
run() 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.
--exe-runner is not set, a function that uses this fixture will
Output path fixture¶
output_path fixture provides the absolute path to the output
directory of a test case as a Path object.
Regression path fixture¶
regression_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 Reference section of a
(thanks to the parametrize feature). The
regression_file_path object has the attributes:
relative: a Path object that contains the path to a reference item relatively to the output directory of the test case.
absolute: a Path object that contains the absolute path to a reference item.
--exe-regression-root is not set then a test function that uses
the fixture is skipped.
You may use this fixture with the Output path fixture to get the path to an output file that shall be compared to a reference file.
For instance, if a
references: - output/file - '**/*.txt'
--exe-regression-root is set to a directory
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
regression_file_path is set as
described above with the relative and absolute paths.
tolerances fixture provides the contents of the Tolerances section
test-settings.yaml as a dictionary that maps names to
For instance, if a
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.