File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
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__ ])
You can’t perform that action at this time.
0 commit comments