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.
Bu egzersiz
Introduction to Testing in Python
kursunun bir parçasıdırUygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
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():
____