Fibonacci module
This is another simple module, but this one has a bug. Later we’ll discuss much more complex cases, but for the understanding of the Pytest testing framework this simple one will do.
It also has some documentation with a few working examples. We’ll see what happens when someone reports a bug in this. We’ll see how are we going to test it.
def fib(n):
"""
Fibonacci sequence 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
>>> fib(7)
8
>>> fib(10)
34
>>> fib(42)
165580141
"""
fibs = [0, 1]
for _ in range(n-2):
fibs.append(fibs[-1] + fibs[-2])
return fibs[-1]