Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add basename parameter documentation #163

Merged
merged 2 commits into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Loading