From 8b37e5628a7192d2628d06acfe4afa2cd6175cc6 Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Fri, 8 Mar 2024 12:03:26 +0000 Subject: [PATCH 1/2] docs: add basename parameter documentation --- doc/overview.rst | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/overview.rst b/doc/overview.rst index f778d54..713c7cc 100644 --- a/doc/overview.rst +++ b/doc/overview.rst @@ -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. @@ -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 +------------------- + +Optionnally 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") From 5f6ff65281b54a80e35a113271e28fa667ee3085 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 8 Mar 2024 09:41:27 -0300 Subject: [PATCH 2/2] Update doc/overview.rst --- doc/overview.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/overview.rst b/doc/overview.rst index 713c7cc..056665c 100644 --- a/doc/overview.rst +++ b/doc/overview.rst @@ -244,7 +244,7 @@ Finally, override the fixtures to use the new options. Generated Filenames ------------------- -Optionnally 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. +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