Create a new script called test_fibonacci.py
, or similar. In this script, write a test function for each of the Fibonacci implementations. Consider the following questions when writing your tests:
Remember that in order for your tests to call your functions, that script will need to import them.
#The approach we've used above, with one test for each function, is fine. But it's very specific to this particular scenario - if we introduced another implementation, we would have to write a new test function for it, which is not the point of modularity. Since our functions are supposed to give the same output, a better approach would be to have one generalised test function which could test any function we pass it.
#numpy.random
module.Copy the functions above (exactly as shown here) into your fibonacci.py
script. Use your tests to find the bugs and compare its output to the previous implementations.