Skip to content

Commit

Permalink
docs: add basename parameter documentation (#163)
Browse files Browse the repository at this point in the history
Co-authored-by: Bruno Oliveira <[email protected]>
  • Loading branch information
12rambau and nicoddemus authored Mar 8, 2024
1 parent 4780978 commit aa5d4c1
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion doc/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ The fixture will generate a ``test_grids2.yml`` file (same name as the test) in
min: 0.36
name: Porosity
This file should be committed to version control.
.. important::

This file should be committed to version control.

The next time you run this test, it will compare the results of ``summary_grids()`` with the contents of the YAML file.
If they match, the test passes. If they don't match the test will fail, showing a nice diff of the text differences.
Expand Down Expand Up @@ -238,3 +240,25 @@ Finally, override the fixtures to use the new options.
def datadir(request) -> pathlib.Path:
config = request.config
return config.rootpath / config.getini('datadir')
Generated Filenames
-------------------

Optionally you can configure the generated filenames by using the ``basename`` parameter of the fixture. The name can be changed to anything as long as it does not conflict with other tests.
In the following example, the filename will be "my_custom_name.yml":

.. code-block:: python
def test_grids3(data_regression, data):
data_regression.check(data, basename="my_custom_name")
.. note::

If one wants to continue using the test name as the filename and only add prefix or suffixes,
It is possible to rely on the `request` fixture to get the test name and use it to generate the filename.

.. code-block:: python
def test_grids3(data_regression, data1, data2, request):
data_regression.check(data1, basename=f"{request.node.name}_data1")
data_regression.check(data2, basename=f"{request.node.name}_data2")

0 comments on commit aa5d4c1

Please sign in to comment.