RedinGhost's picture
Publish curated reproducibility artifact
598316f verified
Raw
History Blame Contribute Delete
710 Bytes
diff --git a/tests/test_number.py b/tests/test_number.py
index 78639c3..0157da3 100644
--- a/tests/test_number.py
+++ b/tests/test_number.py
@@ -193,6 +193,14 @@ def test_fractional(test_input: float | str, expected: str) -> None:
assert humanize.fractional(test_input) == expected
+def test_fractional_accepts_a_denominator_limit() -> None:
+ assert humanize.fractional(0.333, max_denominator=8) == "1/3"
+ assert humanize.fractional(2.2, max_denominator=4) == "2 1/4"
+ assert humanize.fractional(-2.2, max_denominator=4) == "-2 1/4"
+ with pytest.raises(ValueError):
+ humanize.fractional(0.5, max_denominator=0)
+
+
@pytest.mark.parametrize(
"test_args, expected",
[