O'Reilly logo

Python Testing Beginner's Guide by Daniel Arbuckle

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - unit testing during development

  1. The first step is to run the tests. Of course, we have a pretty good idea of what's going to happen; they're all going to fail. Still, it's useful to know exactly what the failures are, because those are the things that we need to address by writing code.
    Time for action - unit testing during development

    There are many more failing tests after that, but you get the idea.

  2. Taking our cue from the tests, and our references on PID controllers, we write the pid.py module:
    from time import time class PID: def __init__(self, P, I, D, setpoint): self.gains = (float(P), float(I), float(D)) self.setpoint = [float(setpoint)] self.previous_time = None self.previous_error ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required