Example #1
0
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)
Example #2
0
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")
Example #3
0
def fact1To25() -> None:
    for i in range(0, 101):
        print('fact(', i, ')=', factorial(i))
Example #4
0
def factorial_view(model: FactorialModel):
    result, time = factorial(model.n)
    return {"result": result, "time": time}
Example #5
0
 def test_factorial24(self):
     """Testing a large number > 2**64
 	"""
     self.assertEqual(factorial(24), 620448401733239439360000)
Example #6
0
 def test_factorial7(self):
     self.assertEqual(factorial(7), 5040)
Example #7
0
 def test_factorial6(self):
     self.assertTrue(factorial(6) == 720)
Example #8
0
 def test_factorial5(self):
     self.assertTrue(factorial(5) == 120)
Example #9
0
 def test_factorial4(self):
     self.assertEqual(factorial(4), 24)
Example #10
0
def test_factorial_float():
    assert factorial.factorial(150) == "none"
    assert factorial.factorial(151) == "none"
Example #11
0
def test_factorial():
    assert factorial.factorial(120) == 5
    assert factorial.factorial(1) == 1
    assert factorial.factorial(2) == 2
    assert factorial.factorial(6) == 3
Example #12
0
 def test_factorial_5_equal_120(self):
     self.assertEqual(factorial(5), 120)
Example #13
0
 def test_factorial_zero_equal_one(self):
     self.assertEqual(factorial(0), 1)
Example #14
0
 def test_factorial_works_not_with_neg_values(self):
     self.assertEqual(factorial(-2), 0)
Example #15
0
def test_factorial_function1():
    assert factorial.factorial(2) == 2
Example #16
0
def test_factorial_zeros():
    assert factorial.factorial(0) == 0