Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion src/pytest_regressions/data_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions tests/test_data_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down
4 changes: 4 additions & 0 deletions tests/test_data_regression/test_integer_keys.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1: first
2: second
10: tenth
100: hundredth