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

The runner fixture is used to execute the runner shell script passed with --exe-runner. This fixture is an object which can execute the script with the 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.

When --exe-runner is not set, a function that uses this fixture will be skipped.

Output path fixture

The output_path fixture provides the absolute path to the output directory of a test case as a Path object.

Regression path fixture

The 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 test-settings.yaml (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.

If --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 test-settings.yaml under inputs/case contains:

   - output/file
   - '**/*.txt'

and if --exe-regression-root is set to a directory references that contains:

└── 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:


and for each these items, the regression_file_path is set as described above with the relative and absolute paths.

Tolerances fixture

The tolerances fixture provides the contents of the Tolerances section of a test-settings.yaml as a dictionary that maps names to Tolerances objects.

For instance, if a test-settings.yaml contains:

        abs: 1.
        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.