diff --git a/src/pytest_regressions/data_regression.py b/src/pytest_regressions/data_regression.py index 6198a6d..b1ddc49 100644 --- a/src/pytest_regressions/data_regression.py +++ b/src/pytest_regressions/data_regression.py @@ -5,6 +5,7 @@ from typing import Callable from typing import Optional from typing import TYPE_CHECKING +from typing import Union import pytest import yaml @@ -36,7 +37,7 @@ def __init__( def check( self, - data_dict: dict[str, Any], + data_dict: dict[Union[str, int], Any], basename: Optional[str] = None, fullpath: Optional["os.PathLike[str]"] = None, round_digits: Optional[int] = None, diff --git a/tests/test_data_regression.py b/tests/test_data_regression.py index 1fc5dc1..ce5c879 100644 --- a/tests/test_data_regression.py +++ b/tests/test_data_regression.py @@ -19,6 +19,17 @@ def test_basename(data_regression): data_regression.check(contents, basename="case.normal") +def test_integer_keys(data_regression): + """Test that integer keys are supported in data dictionaries.""" + contents = { + 1: "first", + 2: "second", + 10: "tenth", + 100: "hundredth", + } + data_regression.check(contents) + + def test_custom_object(data_regression): """Basic example where we register a custom conversion to dump objects""" diff --git a/tests/test_data_regression/test_integer_keys.yml b/tests/test_data_regression/test_integer_keys.yml new file mode 100644 index 0000000..666d4c2 --- /dev/null +++ b/tests/test_data_regression/test_integer_keys.yml @@ -0,0 +1,4 @@ +1: first +2: second +10: tenth +100: hundredth