def test_negatives(self):
		passed = False
		# try:
		# 	factorial.fact(-3)
		# except Exception as e:
		# 	passed = True and (e.message.lower().find("cannot calculate"))>=0
		# self.assertTrue(passed)

		# alternate way
		with self.assertRaises(Exception) as cm:
			factorial.fact(-3)	
 def test_fact(self):
     """
     The actual test.
     Any method which starts with ``test_`` will considered as a test case.
     """
     res = fact(5)
     self.assertEqual(res, 120)
 def test3(self):
     self.assertEqual(fact(4), 24)
Example #4
0
def test_fact():
    res = fact(5)
    assert res == 120
    res1 = fact(7)
    assert res1 == 5040
    assert fact(0) == 1
Example #5
0
# A program that uses a function from a module, for which we are having a test in the tests/ directory

import factorial

print(factorial.fact(7))
Example #6
0
def test_fact():
    assert factorial.fact(3) == 6
Example #7
0
def combo(n, r):
    return fact(n) / (fact(n - r) * fact(r))
def test_count_factorial():
    assert factorial.fact(2) == 2
    def test_fact_2(self):

        res = fact(10)
        self.assertEqual(res, 3628800)
 def test5(self):
     with self.assertRaises(ValueError):
         fact([2, 5, 6])
 def test4(self):
     with self.assertRaises(ValueError):
         fact("")
Example #12
0
 def test_fact(self):
     result = factorial.fact(3)
     self.assertEqual(result,8)
Example #13
0
def perm(n, r):
    return fact(n) / fact(n - r)
Example #14
0
 def test_n(self):
     self.assertEqual(fact(5), 120)
Example #15
0
 def test_TypeError(self):
     with self.assertRaises(TypeError):
         fact(0.5)
Example #16
0
import factorial
x1 = factorial.fact(5)
x2 = factorial.fact2(5)
print(x1)
print(x2)
Example #17
0
 def test_fac_special(self):
     func_output = fact(0)
     self.assertEqual(func_output, 1)
 def test6(self):
     with self.assertRaises(ValueError):
         fact([1])
Example #19
0
import factorial

print(factorial.fact(5))
 def test7(self):
     with self.assertRaises(ValueError):
         fact({3})
Example #21
0
 def test_fact(self):
     """
 实际测试中以 test_都是测试用例
 """
     res = fact(5)
     self.assertEqual(res, 120)
 def test8(self):
     with self.assertRaises(ValueError):
         fact(5.1)
 def test_factorial(self):
     n = 5
     self.assertEqual(factorial.fact(n), n*factorial.fact(n-1))
 def test9(self):
     with self.assertRaises(ValueError):
         fact(-1)
Example #25
0
def main():
    print(" in-built functions of imported module : ",
          dir(fact))  # list all the functions and variables in the module
    x = 5
    print(" factorial ", x, "=",
          fact.fact(x))  # accessing variable of fact module
 def test1(self):
     self.assertEqual(fact(1), 1)
Example #27
0
 def test_fact(self):
     res = fact(5)
     self.assertEqual(res, 120)
 def test2(self):
     self.assertEqual(fact(2), 2)
def cosine(point,order):
	aux = 0
	for i in range(order -1 ):
		aux = aux + ((-1)**i *(point**(2 * i)))/fact(2 * i)
	return Decimal(aux)
Example #30
0
def test_1():
    """

    :return:
    """
    assert factorial.fact(1) == 1
	def test_positives(self):
		for x in range(0,10+1):
			act = math.factorial(x)
			val = factorial.fact(x)
			print "%d! = %g == %g" %(x,val,act)
			self.assertAlmostEqual(act,val,1e-1)
Example #32
0
def test_5():
    """

    :return:
    """
    assert factorial.fact(5) == 120
Example #33
0
def test_0():
    """

    :return:
    """
    assert factorial.fact(0) == 1
Example #34
0
 def test_fac(self):
     func_output = fact(7)
     self.assertEqual(func_output, 5040)