We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b26aa31 commit f92f9dcCopy full SHA for f92f9dc
.gitignore
@@ -23,3 +23,4 @@
23
/169/README.md
24
/172/README.md
25
/21/README.md
26
+/238/README.md
238/fibonacci.py
@@ -0,0 +1,7 @@
1
+def fib(n):
2
+ if n < 0:
3
+ raise ValueError
4
+ elif n in (0, 1):
5
+ return n
6
+ else:
7
+ return (fib(n - 1) + fib(n - 2))
238/test_fibonacci.py
@@ -0,0 +1,24 @@
+import pytest
+from fibonacci import fib
+
+def test_nlt0():
+ with pytest.raises(ValueError):
+ fib(-1)
8
9
10
+def test_0():
11
+ assert fib(0) == 0
12
13
14
+def test_1():
15
+ assert fib(1) == 1
16
17
18
+def test_2():
19
+ assert fib(2) == 1
20
21
22
+def test_3():
+ assert fib(3) == 2
+# write one or more pytest functions below, they need to start with test_
0 commit comments