diff --git a/tests/test_number.py b/tests/test_number.py index 5fb12fa6..4db0134d 100644 --- a/tests/test_number.py +++ b/tests/test_number.py @@ -83,6 +83,25 @@ def test_intcomma( assert humanize.intcomma(*test_args) == expected +@pytest.mark.parametrize( + "thousands_sep, decimal_sep, expected", + [ + (".", ",", "1.234.567,89"), + (" ", ",", "1 234 567,89"), + ], +) +def test_intcomma_localized_separators( + monkeypatch: pytest.MonkeyPatch, + thousands_sep: str, + decimal_sep: str, + expected: str, +) -> None: + monkeypatch.setattr(number, "thousands_separator", lambda: thousands_sep) + monkeypatch.setattr(number, "decimal_separator", lambda: decimal_sep) + + assert humanize.intcomma(1234567.89) == expected + + @pytest.mark.parametrize("sign", [1, -1]) def test_intcomma_large_integer(sign: int) -> None: value = sign * (10**400 + 123) @@ -297,6 +316,11 @@ def test_clamp(test_args: list[typing.Any], expected: str) -> None: assert humanize.clamp(*test_args) == expected +def test_clamp_invalid_format() -> None: + with pytest.raises(ValueError, match="Invalid format"): + humanize.clamp(10, format=123) + + @pytest.mark.parametrize( "test_args, expected", [