From 18e8104041610c32f9dedff6740688c4d1934550 Mon Sep 17 00:00:00 2001 From: tthijm <59415467+tthijm@users.noreply.github.com> Date: Wed, 12 Jun 2024 14:33:54 +0200 Subject: [PATCH] Add test --- tests/test_utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_utils.py b/tests/test_utils.py index 5f8060d52c52..720bb0249dbd 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -334,3 +334,16 @@ def test_is_inside_class(): ) def test_format_dt(dt: datetime.datetime, style: typing.Optional[utils.TimestampStyle], formatted: str): assert utils.format_dt(dt, style=style) == formatted + + +@pytest.mark.parametrize( + ("parameters", "flattened"), + [ + ([], ()), + ([0, 1, 2], (0, 1, 2)), + ([0, typing.Literal["a", 1], "b"], (0, "a", 1, "b")), + ([0, "a", typing.Literal[1, typing.Literal["b", 2]], typing.Literal["c"]], (0, "a", 1, "b", 2, "c")), + ], +) +def test_flatten_literal_params(parameters: typing.Iterable[typing.Any], flattened: typing.Tuple[typing.Any, ...]) -> None: + assert utils.flatten_literal_params(parameters) == flattened