Exemple #1
0
 def test_fibonacciPosReturnsUnderRandomOrderLoad(self):
     for _ in range(LOAD_RUNS):
         try:
             pos = random.randint(0,LOAD_RUNS) 
             fibonacci_pos(pos)
         except:
             self.assertTrue(False)
             return
     self.assertTrue(True)
Exemple #2
0
    def test_fibonacciPosReturnsUnderLoadBackward(self):
        for pos in range(LOAD_RUNS,0,-1):
#            with self.subTest(pos=pos):
            try:
                fibonacci_pos(pos)
            except:
                self.assertTrue(False)
                return
        self.assertTrue(True)
Exemple #3
0
    def test_fibonacciPosReturnsCorrectValuesOutOfSequence(self):
        for pos, val in [(10,55),(2,1),(12,144),(14,377),(0,0)]:
#            with self.subTest(pos=pos, val=val):
            self.assertEqual(fibonacci_pos(pos),val)
Exemple #4
0
 def test_fibonacci_posDoesntRunWithListArgument(self):
     with self.assertRaises(AssertionError):
         fibonacci_pos([1123, 5813])
Exemple #5
0
    def test_fibonacciReturnsCorrectValuesinSequence(self):
        for i, val in enumerate([0,1,1,2,3,5,8,13,21,34,55,89,144,233,377]):
#            with self.subTest(pos=i):
            self.assertEqual(fibonacci_pos(i),val)
Exemple #6
0
 def test_fibonacci_posDoesntRunWithTupleArgument(self):
     with self.assertRaises(AssertionError):
         fibonacci_pos((1123, 5813))
Exemple #7
0
 def test_fibonacci_posDoesntRunWithOneFloat(self):
     with self.assertRaises(AssertionError):
         fibonacci_pos(58.13)
Exemple #8
0
 def test_fibonacci_posDoesntRunWithNegativeArgument(self):
     with self.assertRaises(AssertionError):
         fibonacci_pos(-1)
Exemple #9
0
    def test_fibonacci_posDoesntRunWithTooManyRightTypeArguments(self):
        for pos in range(2, 12):
#            with self.subTest(pos=pos) and
            with self.assertRaises(TypeError):
                fibonacci_pos(*[x for x in range(pos)])
Exemple #10
0
 def test_fibonacci_posDoesntRunWithNoArguments(self):
     with self.assertRaises(TypeError):
         fibonacci_pos()