Test the Fibonacci separated
Just as in the previous case, we can separate the test-cases into separate functions. Soon we’ll see the real value of this separation.
import unittest
from fibonacci import fib
class TestFibo(unittest.TestCase):
def test_7(self):
self.assertEqual(fib(7), 8)
def test_10(self):
self.assertEqual(fib(10), 34)
def test_42(self):
self.assertEqual(fib(42), 165580141)
$ python -m unittest test_fibonacci_with_unittest_separated.py
...
-------------------------------------------------------------
Ran 3 tests in 0.000s
OK