Skip to content

Commit 945ac9c

Browse files
authored
Merge branch 'master' into more-ruff-ignore
2 parents 372ee36 + 7665ba5 commit 945ac9c

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

maths/test_factorial.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# /// script
2+
# requires-python = ">=3.13"
3+
# dependencies = [
4+
# "pytest",
5+
# ]
6+
# ///
7+
8+
import pytest
9+
10+
from maths.factorial import factorial, factorial_recursive
11+
12+
13+
@pytest.mark.parametrize("function", [factorial, factorial_recursive])
14+
def test_zero(function):
15+
assert function(0) == 1
16+
17+
18+
@pytest.mark.parametrize("function", [factorial, factorial_recursive])
19+
def test_positive_integers(function):
20+
assert function(1) == 1
21+
assert function(5) == 120
22+
assert function(7) == 5040
23+
24+
25+
@pytest.mark.parametrize("function", [factorial, factorial_recursive])
26+
def test_large_number(function):
27+
assert function(10) == 3628800
28+
29+
30+
@pytest.mark.parametrize("function", [factorial, factorial_recursive])
31+
def test_negative_number(function):
32+
with pytest.raises(ValueError):
33+
function(-3)
34+
35+
36+
if __name__ == "__main__":
37+
pytest.main(["-v", __file__])

0 commit comments

Comments
 (0)