Time for action - testing PID with unittest

We'll revisit the PID class (or at least the tests for the PID class) from Chapter 3. We'll rewrite the tests so that they operate within the unittest framework.

Before moving on, take a moment to refer back to the final version of the pid.txt file from Chapter 3. We'll be implementing the same tests using the unittest framework.

  1. Create a new file called test_pid.py in the same directory as pid.py. Notice that this is a .py file: unittest tests are pure python source code, rather than being plain text with source code embedded in it. That means the tests will be less useful from a documentary point of view, but grants other benefits in exchange.
  2. Insert the following code into your newly-created test_pid.py ...

Get Python Testing Beginner's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.