def test_factorial_with_valid_data(): """Function tests factorial with valid data""" factorial_sequence = [math.factorial(num) for num in range(10)] for index, value in enumerate(factorial_sequence): fact, _ = factorial(index) assert fact == value fact, _ = factorial(15) assert fact == math.factorial(15)
def test_factorial_raises_exception_with_invalid_values(): """Function tests Factorial with invalid input 1. Negative value input 2. Value that exceeds the max limit 3. Non-integer value """ with pytest.raises(ValidationError): factorial(-1) with pytest.raises(ValidationError): factorial(config.FACTORIAL_MAX_VALUE + 1) with pytest.raises(TypeError): factorial("string")
def fact1To25() -> None: for i in range(0, 101): print('fact(', i, ')=', factorial(i))
def factorial_view(model: FactorialModel): result, time = factorial(model.n) return {"result": result, "time": time}
def test_factorial24(self): """Testing a large number > 2**64 """ self.assertEqual(factorial(24), 620448401733239439360000)
def test_factorial7(self): self.assertEqual(factorial(7), 5040)
def test_factorial6(self): self.assertTrue(factorial(6) == 720)
def test_factorial5(self): self.assertTrue(factorial(5) == 120)
def test_factorial4(self): self.assertEqual(factorial(4), 24)
def test_factorial_float(): assert factorial.factorial(150) == "none" assert factorial.factorial(151) == "none"
def test_factorial(): assert factorial.factorial(120) == 5 assert factorial.factorial(1) == 1 assert factorial.factorial(2) == 2 assert factorial.factorial(6) == 3
def test_factorial_5_equal_120(self): self.assertEqual(factorial(5), 120)
def test_factorial_zero_equal_one(self): self.assertEqual(factorial(0), 1)
def test_factorial_works_not_with_neg_values(self): self.assertEqual(factorial(-2), 0)
def test_factorial_function1(): assert factorial.factorial(2) == 2
def test_factorial_zeros(): assert factorial.factorial(0) == 0