Pytest expected exception
examples/pytest/fib2/fibonacci.py
def fib(n): if n < 1: raise ValueError(f'Invalid parameter {n}') a, b = 1, 1 for _ in range(1, n): a, b = b, a+b return a
examples/pytest/fib2/use_fib.py
from fibonacci import fib print(fib(10)) print(fib(-3))
55 Traceback (most recent call last): File "use_fib.py", line 4, in <module> print(fib(-1)) File "fibonacci.py", line 3, in fib raise ValueError(f'Invalid parameter {n}') ValueError: Invalid parameter -1