How to Use Unit Tests for Debugging in Python 3


show more Using unit tests provides you with in-depth training on Developer. Taught by Bill Weinman as part of the Python 3 Essential Training show less
please wait ...

Using unit tests

The Python standard library includes a unit test module that's very powerful and very flexible and is also very easy to use. Unit tests are valuable for a few reasons. Unit tests are automated tests that you can run on your code and you can write these tests once and save them and run them over and over. So if you have a set of code that's got a lifetime to it, that over the course of its lifetime it gets updated, it gets changed, having these unit tests already written and being able to run these unit tests on your code is going to have some real value for you.

So let's look at how this is done in Python. I've got the saytime module here, which has been used for a number of different purposes in this course. And you'll notice at the end of it it's got a little test function. And when I wrote this, this just seemed like the easiest way to do it. And it's also, I like to be able to look at the results and say yeah, that looks right. That looks right. That looks ri...

Using unit tests
Video duration: 6m 30s 6h 36m Beginner

Viewers:

Using unit tests provides you with in-depth training on Developer. Taught by Bill Weinman as part of the Python 3 Essential Training

Subjects:
Developer Web
Software:
Python
Author:
please wait ...