From 76d88df1187960f1056c0bad1d8621320753c207 Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Tue, 17 Dec 2024 07:22:22 +0000 Subject: [PATCH 01/15] feat: add rounding capabilities to data_regression --- src/pytest_regressions/common.py | 22 +++++++++++++++++++ src/pytest_regressions/data_regression.py | 7 ++++++ tests/test_data_regression.py | 9 ++++++++ .../test_round_digits.yml | 4 ++++ 4 files changed, 42 insertions(+) create mode 100644 tests/test_data_regression/test_round_digits.yml diff --git a/src/pytest_regressions/common.py b/src/pytest_regressions/common.py index 30f118d..e3f13c7 100644 --- a/src/pytest_regressions/common.py +++ b/src/pytest_regressions/common.py @@ -4,6 +4,7 @@ from typing import Callable from typing import List from typing import Optional +from typing import Union import pytest @@ -188,3 +189,24 @@ def make_location_message(banner: str, filename: Path, aux_files: List[str]) -> else: dump_aux_fn(Path(obtained_filename)) raise + + +def round_digits(data: Union[list, dict], prescision: int) -> Union[list, dict]: + """ + Recusrsively Round the values of any float value in a collection to the given prescision. + + :param data: The collection to round. + :param prescision: The number of decimal places to round to. + :return: The collection with all float values rounded to the given prescision. + + """ + # change the generator depending on the collection type + generator = enumerate(data) if isinstance(data, list) else data.items() + for k, v in generator: + if isinstance(v, (list, dict)): + data[k] = round_digits(v, prescision) + elif isinstance(v, float): + data[k] = round(v, prescision) + else: + data[k] = v + return data diff --git a/src/pytest_regressions/data_regression.py b/src/pytest_regressions/data_regression.py index 70a1d09..46874ee 100644 --- a/src/pytest_regressions/data_regression.py +++ b/src/pytest_regressions/data_regression.py @@ -11,6 +11,7 @@ from .common import check_text_files from .common import perform_regression_check +from .common import round_digits class DataRegressionFixture: @@ -32,6 +33,7 @@ def check( data_dict: Dict[str, Any], basename: Optional[str] = None, fullpath: Optional["os.PathLike[str]"] = None, + prescision: Optional[int] = None, ) -> None: """ Checks the given dict against a previously recorded version, or generate a new file. @@ -46,10 +48,15 @@ def check( will ignore ``datadir`` fixture when reading *expected* files but will still use it to write *obtained* files. Useful if a reference file is located in the session data dir for example. + :param prescision: if given, round all floats in the dict to the given number of digits. + ``basename`` and ``fullpath`` are exclusive. """ __tracebackhide__ = True + if prescision is not None: + data_dict = round_digits(data_dict, prescision) + def dump(filename: Path) -> None: """Dump dict contents to the given filename""" import yaml diff --git a/tests/test_data_regression.py b/tests/test_data_regression.py index c36e003..d79b5cf 100644 --- a/tests/test_data_regression.py +++ b/tests/test_data_regression.py @@ -38,6 +38,15 @@ def dump_scalar(dumper, scalar): data_regression.check(contents) +def test_round_digits(data_regression): + """Example including float numbers and check rounding capabilities.""" + contents = { + "content": {"value1": "toto", "value": 1.123456789}, + "value": 1.23456789, + } + data_regression.check(contents, prescision=2) + + def test_usage_workflow(pytester, monkeypatch): monkeypatch.setattr( sys, "testing_get_data", lambda: {"contents": "Foo", "value": 10}, raising=False diff --git a/tests/test_data_regression/test_round_digits.yml b/tests/test_data_regression/test_round_digits.yml new file mode 100644 index 0000000..ea5f70a --- /dev/null +++ b/tests/test_data_regression/test_round_digits.yml @@ -0,0 +1,4 @@ +content: + value: 1.12 + value1: toto +value: 1.23 From 046ad5924d6cb96ba3789902820c22e539739800 Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Tue, 17 Dec 2024 07:24:18 +0000 Subject: [PATCH 02/15] fix: remove double import --- src/pytest_regressions/data_regression.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pytest_regressions/data_regression.py b/src/pytest_regressions/data_regression.py index 46874ee..33a8a47 100644 --- a/src/pytest_regressions/data_regression.py +++ b/src/pytest_regressions/data_regression.py @@ -59,7 +59,6 @@ def check( def dump(filename: Path) -> None: """Dump dict contents to the given filename""" - import yaml dumped_str = yaml.dump_all( [data_dict], From a3fb8e93b872fe77fda1b542a4eea3ba8e59c24c Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:13:40 +0100 Subject: [PATCH 03/15] Update src/pytest_regressions/common.py Co-authored-by: Bruno Oliveira --- src/pytest_regressions/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytest_regressions/common.py b/src/pytest_regressions/common.py index e3f13c7..40f45f5 100644 --- a/src/pytest_regressions/common.py +++ b/src/pytest_regressions/common.py @@ -193,7 +193,7 @@ def make_location_message(banner: str, filename: Path, aux_files: List[str]) -> def round_digits(data: Union[list, dict], prescision: int) -> Union[list, dict]: """ - Recusrsively Round the values of any float value in a collection to the given prescision. + Recursively Round the values of any float value in a collection to the given precision. :param data: The collection to round. :param prescision: The number of decimal places to round to. From 3285727d24aa14b3b2211aa326eecc4eecda095d Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:06:59 +0100 Subject: [PATCH 04/15] Update src/pytest_regressions/common.py Co-authored-by: Bruno Oliveira --- src/pytest_regressions/common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pytest_regressions/common.py b/src/pytest_regressions/common.py index 40f45f5..1cce7d8 100644 --- a/src/pytest_regressions/common.py +++ b/src/pytest_regressions/common.py @@ -201,9 +201,9 @@ def round_digits(data: Union[list, dict], prescision: int) -> Union[list, dict]: """ # change the generator depending on the collection type - generator = enumerate(data) if isinstance(data, list) else data.items() + generator = enumerate(data) if isinstance(data, MutableSequence) else data.items() for k, v in generator: - if isinstance(v, (list, dict)): + if isinstance(v, (MutableSequence, MutableMapping)): data[k] = round_digits(v, prescision) elif isinstance(v, float): data[k] = round(v, prescision) From 1903df15269091bec9fca60ad3cdf8f75c96d1fc Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:07:16 +0100 Subject: [PATCH 05/15] Update src/pytest_regressions/common.py Co-authored-by: Bruno Oliveira --- src/pytest_regressions/common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pytest_regressions/common.py b/src/pytest_regressions/common.py index 1cce7d8..c704572 100644 --- a/src/pytest_regressions/common.py +++ b/src/pytest_regressions/common.py @@ -191,7 +191,9 @@ def make_location_message(banner: str, filename: Path, aux_files: List[str]) -> raise -def round_digits(data: Union[list, dict], prescision: int) -> Union[list, dict]: +T = TypeVar("T", bound=Union[MutableSequence, MutableMapping]) + +def round_digits(data: T, precision: int) -> T: """ Recursively Round the values of any float value in a collection to the given precision. From 76fa6daab17b13378fd8d3bd453c90d664fd674f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:07:22 +0000 Subject: [PATCH 06/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/pytest_regressions/common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pytest_regressions/common.py b/src/pytest_regressions/common.py index c704572..db2b6b7 100644 --- a/src/pytest_regressions/common.py +++ b/src/pytest_regressions/common.py @@ -193,6 +193,7 @@ def make_location_message(banner: str, filename: Path, aux_files: List[str]) -> T = TypeVar("T", bound=Union[MutableSequence, MutableMapping]) + def round_digits(data: T, precision: int) -> T: """ Recursively Round the values of any float value in a collection to the given precision. From acc6c72dbf0b79fd552958fa1461b464b4a8e032 Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:08:28 +0100 Subject: [PATCH 07/15] Update tests/test_data_regression.py Co-authored-by: Bruno Oliveira --- tests/test_data_regression.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_data_regression.py b/tests/test_data_regression.py index d79b5cf..25d210c 100644 --- a/tests/test_data_regression.py +++ b/tests/test_data_regression.py @@ -42,9 +42,18 @@ def test_round_digits(data_regression): """Example including float numbers and check rounding capabilities.""" contents = { "content": {"value1": "toto", "value": 1.123456789}, + "values": [1.12345, 2.34567], "value": 1.23456789, } - data_regression.check(contents, prescision=2) + data_regression.check(contents, precision=2) + + with pytest.raises(AssertionError): + contents = { + "content": {"value1": "toto", "value": 1.2345678}, + "values": [1.13456, 2.45678], + "value": 1.23456789, + } + data_regression.check(contents, precision=2) def test_usage_workflow(pytester, monkeypatch): From 009a0d3b3e368eb635877ee50a41dc46d820bb5f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:08:40 +0000 Subject: [PATCH 08/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_data_regression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_data_regression.py b/tests/test_data_regression.py index 25d210c..3fea887 100644 --- a/tests/test_data_regression.py +++ b/tests/test_data_regression.py @@ -46,7 +46,7 @@ def test_round_digits(data_regression): "value": 1.23456789, } data_regression.check(contents, precision=2) - + with pytest.raises(AssertionError): contents = { "content": {"value1": "toto", "value": 1.2345678}, From 4f6bfe7444899b03d3615da37bfe6a60da5f1f47 Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:24:44 +0100 Subject: [PATCH 09/15] Update src/pytest_regressions/data_regression.py Co-authored-by: Bruno Oliveira --- src/pytest_regressions/data_regression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytest_regressions/data_regression.py b/src/pytest_regressions/data_regression.py index 33a8a47..b549727 100644 --- a/src/pytest_regressions/data_regression.py +++ b/src/pytest_regressions/data_regression.py @@ -55,7 +55,7 @@ def check( __tracebackhide__ = True if prescision is not None: - data_dict = round_digits(data_dict, prescision) + round_digits(data_dict, prescision) def dump(filename: Path) -> None: """Dump dict contents to the given filename""" From 8c5b1b34219bb53a317cbce1581acd8297fd3de5 Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:39:34 +0000 Subject: [PATCH 10/15] test: regenerate regression file --- src/pytest_regressions/common.py | 11 +++++++---- src/pytest_regressions/data_regression.py | 8 ++++---- tests/test_data_regression.py | 1 + tests/test_data_regression/test_round_digits.yml | 3 +++ 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/pytest_regressions/common.py b/src/pytest_regressions/common.py index db2b6b7..0655652 100644 --- a/src/pytest_regressions/common.py +++ b/src/pytest_regressions/common.py @@ -3,7 +3,10 @@ from pathlib import Path from typing import Callable from typing import List +from typing import MutableMapping +from typing import MutableSequence from typing import Optional +from typing import TypeVar from typing import Union import pytest @@ -199,17 +202,17 @@ def round_digits(data: T, precision: int) -> T: Recursively Round the values of any float value in a collection to the given precision. :param data: The collection to round. - :param prescision: The number of decimal places to round to. - :return: The collection with all float values rounded to the given prescision. + :param precision: The number of decimal places to round to. + :return: The collection with all float values rounded to the given precision. """ # change the generator depending on the collection type generator = enumerate(data) if isinstance(data, MutableSequence) else data.items() for k, v in generator: if isinstance(v, (MutableSequence, MutableMapping)): - data[k] = round_digits(v, prescision) + data[k] = round_digits(v, precision) elif isinstance(v, float): - data[k] = round(v, prescision) + data[k] = round(v, precision) else: data[k] = v return data diff --git a/src/pytest_regressions/data_regression.py b/src/pytest_regressions/data_regression.py index b549727..e9c40c6 100644 --- a/src/pytest_regressions/data_regression.py +++ b/src/pytest_regressions/data_regression.py @@ -33,7 +33,7 @@ def check( data_dict: Dict[str, Any], basename: Optional[str] = None, fullpath: Optional["os.PathLike[str]"] = None, - prescision: Optional[int] = None, + precision: Optional[int] = None, ) -> None: """ Checks the given dict against a previously recorded version, or generate a new file. @@ -48,14 +48,14 @@ def check( will ignore ``datadir`` fixture when reading *expected* files but will still use it to write *obtained* files. Useful if a reference file is located in the session data dir for example. - :param prescision: if given, round all floats in the dict to the given number of digits. + :param precision: if given, round all floats in the dict to the given number of digits. ``basename`` and ``fullpath`` are exclusive. """ __tracebackhide__ = True - if prescision is not None: - round_digits(data_dict, prescision) + if precision is not None: + round_digits(data_dict, precision) def dump(filename: Path) -> None: """Dump dict contents to the given filename""" diff --git a/tests/test_data_regression.py b/tests/test_data_regression.py index 3fea887..3cd9acd 100644 --- a/tests/test_data_regression.py +++ b/tests/test_data_regression.py @@ -1,6 +1,7 @@ import sys from textwrap import dedent +import pytest import yaml from pytest_regressions.testing import check_regression_fixture_workflow diff --git a/tests/test_data_regression/test_round_digits.yml b/tests/test_data_regression/test_round_digits.yml index ea5f70a..54cc585 100644 --- a/tests/test_data_regression/test_round_digits.yml +++ b/tests/test_data_regression/test_round_digits.yml @@ -2,3 +2,6 @@ content: value: 1.12 value1: toto value: 1.23 +values: +- 1.12 +- 2.35 From 05c4c4b381b47c3643ae19f84d90789f62927b56 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 17 Dec 2024 10:14:49 -0300 Subject: [PATCH 11/15] Apply suggestions from code review --- src/pytest_regressions/common.py | 26 ++++++++++++++--------- src/pytest_regressions/data_regression.py | 9 ++++---- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/pytest_regressions/common.py b/src/pytest_regressions/common.py index 0655652..c12a01f 100644 --- a/src/pytest_regressions/common.py +++ b/src/pytest_regressions/common.py @@ -197,22 +197,28 @@ def make_location_message(banner: str, filename: Path, aux_files: List[str]) -> T = TypeVar("T", bound=Union[MutableSequence, MutableMapping]) -def round_digits(data: T, precision: int) -> T: +def round_digits(data: T, digits: int) -> T: """ - Recursively Round the values of any float value in a collection to the given precision. - - :param data: The collection to round. - :param precision: The number of decimal places to round to. - :return: The collection with all float values rounded to the given precision. - + Recursively round the values of any float value in a collection to the given number of digits. The rounding is done in-place. + + :param data: + The collection to round. + + :param digits: + The number of digits to round to. + + :return: + The collection with all float values rounded to the given precision. + Note that the rounding is done in-place, so this return value only exists + because we use the function recursively. """ - # change the generator depending on the collection type + # Change the generator depending on the collection type. generator = enumerate(data) if isinstance(data, MutableSequence) else data.items() for k, v in generator: if isinstance(v, (MutableSequence, MutableMapping)): - data[k] = round_digits(v, precision) + data[k] = round_digits(v, digits) elif isinstance(v, float): - data[k] = round(v, precision) + data[k] = round(v, digits) else: data[k] = v return data diff --git a/src/pytest_regressions/data_regression.py b/src/pytest_regressions/data_regression.py index e9c40c6..9bf0c9a 100644 --- a/src/pytest_regressions/data_regression.py +++ b/src/pytest_regressions/data_regression.py @@ -33,7 +33,7 @@ def check( data_dict: Dict[str, Any], basename: Optional[str] = None, fullpath: Optional["os.PathLike[str]"] = None, - precision: Optional[int] = None, + round_digits: Optional[int] = None, ) -> None: """ Checks the given dict against a previously recorded version, or generate a new file. @@ -48,14 +48,15 @@ def check( will ignore ``datadir`` fixture when reading *expected* files but will still use it to write *obtained* files. Useful if a reference file is located in the session data dir for example. - :param precision: if given, round all floats in the dict to the given number of digits. + :param round_digits: + If given, round all floats in the dict to the given number of digits. ``basename`` and ``fullpath`` are exclusive. """ __tracebackhide__ = True - if precision is not None: - round_digits(data_dict, precision) + if round_digits is not None: + round_digits(data_dict, round_digits) def dump(filename: Path) -> None: """Dump dict contents to the given filename""" From b9ac135a42b9ff9b9ef8598589b05a401b0faa2f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:14:57 +0000 Subject: [PATCH 12/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/pytest_regressions/common.py | 8 ++++---- src/pytest_regressions/data_regression.py | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pytest_regressions/common.py b/src/pytest_regressions/common.py index c12a01f..3176c71 100644 --- a/src/pytest_regressions/common.py +++ b/src/pytest_regressions/common.py @@ -201,13 +201,13 @@ def round_digits(data: T, digits: int) -> T: """ Recursively round the values of any float value in a collection to the given number of digits. The rounding is done in-place. - :param data: + :param data: The collection to round. - :param digits: + :param digits: The number of digits to round to. - - :return: + + :return: The collection with all float values rounded to the given precision. Note that the rounding is done in-place, so this return value only exists because we use the function recursively. diff --git a/src/pytest_regressions/data_regression.py b/src/pytest_regressions/data_regression.py index 9bf0c9a..8293ef4 100644 --- a/src/pytest_regressions/data_regression.py +++ b/src/pytest_regressions/data_regression.py @@ -11,7 +11,6 @@ from .common import check_text_files from .common import perform_regression_check -from .common import round_digits class DataRegressionFixture: @@ -48,7 +47,7 @@ def check( will ignore ``datadir`` fixture when reading *expected* files but will still use it to write *obtained* files. Useful if a reference file is located in the session data dir for example. - :param round_digits: + :param round_digits: If given, round all floats in the dict to the given number of digits. ``basename`` and ``fullpath`` are exclusive. From f0858cc6a1fc5c5d2a30427667b4f0a7a787b7de Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 17 Dec 2024 10:15:31 -0300 Subject: [PATCH 13/15] Apply suggestions from code review --- tests/test_data_regression.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_data_regression.py b/tests/test_data_regression.py index 3cd9acd..1fc5dc1 100644 --- a/tests/test_data_regression.py +++ b/tests/test_data_regression.py @@ -46,7 +46,7 @@ def test_round_digits(data_regression): "values": [1.12345, 2.34567], "value": 1.23456789, } - data_regression.check(contents, precision=2) + data_regression.check(contents, round_digits=2) with pytest.raises(AssertionError): contents = { @@ -54,7 +54,7 @@ def test_round_digits(data_regression): "values": [1.13456, 2.45678], "value": 1.23456789, } - data_regression.check(contents, precision=2) + data_regression.check(contents, round_digits=2) def test_usage_workflow(pytester, monkeypatch): From 325f3f02d977fb44871aad53aaed3d79148787ad Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 17 Dec 2024 10:17:14 -0300 Subject: [PATCH 14/15] Update CHANGELOG.rst --- CHANGELOG.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ce85303..18aa5a5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,8 @@ UNRELEASED ---------- -* `#132 `__: Add documentation for specifying custom data directories. +* `#132 `__: Added documentation for specifying custom data directories. +* `#177 `__: Added new `round_digits` to `data_regression.check`, which when given will round all float values to the given number of dicts (recursively) before saving the data to disk. 2.5.0 (2023-08-31) ------------------ From b866349e9f49e07bd80c1552c4bc892f6bb079c9 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 17 Dec 2024 10:25:57 -0300 Subject: [PATCH 15/15] Fix names --- CHANGELOG.rst | 2 +- src/pytest_regressions/common.py | 4 ++-- src/pytest_regressions/data_regression.py | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 18aa5a5..a7569b0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,7 +2,7 @@ UNRELEASED ---------- * `#132 `__: Added documentation for specifying custom data directories. -* `#177 `__: Added new `round_digits` to `data_regression.check`, which when given will round all float values to the given number of dicts (recursively) before saving the data to disk. +* `#177 `__: Added new ``round_digits`` to ``data_regression.check``, which when given will round all float values to the given number of dicts (recursively) before saving the data to disk. 2.5.0 (2023-08-31) ------------------ diff --git a/src/pytest_regressions/common.py b/src/pytest_regressions/common.py index 3176c71..4992f11 100644 --- a/src/pytest_regressions/common.py +++ b/src/pytest_regressions/common.py @@ -197,7 +197,7 @@ def make_location_message(banner: str, filename: Path, aux_files: List[str]) -> T = TypeVar("T", bound=Union[MutableSequence, MutableMapping]) -def round_digits(data: T, digits: int) -> T: +def round_digits_in_data(data: T, digits: int) -> T: """ Recursively round the values of any float value in a collection to the given number of digits. The rounding is done in-place. @@ -216,7 +216,7 @@ def round_digits(data: T, digits: int) -> T: generator = enumerate(data) if isinstance(data, MutableSequence) else data.items() for k, v in generator: if isinstance(v, (MutableSequence, MutableMapping)): - data[k] = round_digits(v, digits) + data[k] = round_digits_in_data(v, digits) elif isinstance(v, float): data[k] = round(v, digits) else: diff --git a/src/pytest_regressions/data_regression.py b/src/pytest_regressions/data_regression.py index 8293ef4..b86298e 100644 --- a/src/pytest_regressions/data_regression.py +++ b/src/pytest_regressions/data_regression.py @@ -11,6 +11,7 @@ from .common import check_text_files from .common import perform_regression_check +from .common import round_digits_in_data class DataRegressionFixture: @@ -55,7 +56,7 @@ def check( __tracebackhide__ = True if round_digits is not None: - round_digits(data_dict, round_digits) + round_digits_in_data(data_dict, round_digits) def dump(filename: Path) -> None: """Dump dict contents to the given filename"""