예제 #1
0
 def test_negative_number(self):
     """
     Calling fibonacci at a negative number should raise an index error.
     """
     with self.assertRaises(IndexError):
         fibonacci_n(-2)
예제 #2
0
 def test_positive_numbers(self):
     """
     Calling fibonacci with a positive number should return a
     """
     self.assertListEqual(list(fibonacci_n(5)), [0, 1, 1, 2, 3])
     self.assertListEqual(list(fibonacci_n(8)), [0, 1, 1, 2, 3, 5, 8, 13])
예제 #3
0
 def test_not_a_number(self):
     with self.assertRaises(TypeError):
         fibonacci_n("EMC Cloud Services")
예제 #4
0
 def test_zero_length(self):
     """
     Calling fibonacci(0) should return an empty list.
     """
     self.assertListEqual(list(fibonacci_n(0)), [])