Assignment #07: Exceptions and Testing

Assignment #07: Exceptions and Testing#

In today’s assignment we will revisit old code in order to properly test it and make it more robust.

Exercise #07-01: Refactor and test old code#

  • Write a test suite for three of the following past exercises: “#03-01 and #03-02: cryptography”, “#04-01: automated data download”, “#05-03: BSE”, and “#07-01: Galton Board” (one test_*.py file per module). The test suite must contain unit tests for each function you programmed. While doing so, you might find it very useful to refactor your code following the good practices: write small functions with a task clearly defined for which you can test. If you cannot test it, the function is possibly not written the right way: either too broad, or not useful enough.

  • Apply the exception handling methods learned in the Exceptions chapter to the download function(s) of exercise #04-01. Add a test to your test suite to verify that exceptions are raised when an invalid tile is requested for download.