Factorial of number
You will implement pytest
tests using the provided test cases to test the factorial
function. The factorial
function of n
is the product of all positive integers less than or equal to n
. It is guaranteed that n
is a non-negative integer. At each step, you will get a test case that you need to implement in Python
. The pytest
library was already imported for you.
This exercise is part of the course
Introduction to Testing in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
def factorial(n):
if n == 0: return 1
elif (type(n) == int):
return n * factorial(n-1)
else: return -1
# Test case: expected input
def test_regular():
____