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

Chapter 5. When Doctest isn't Enough: Unittest to the Rescue

As the tests get more detailed (or complex), or they require more setup code to prepare the way for them, doctest begins to get a little bit annoying. The very simplicity that makes it the best way to write testable specifications and other simple tests starts to interfere with writing tests for complicated things.

In this chapter we shall:

  • Learn how to write and execute tests in the unittest framework
  • Learn how to express familiar testing concepts using unittest
  • Discuss the specific features that make unittest suitable for more complicated testing scenarios
  • Learn about of couple of Mocker's features that integrate well with unittest

So let's get on with it!

Basic unittest

Before we start talking ...

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