Skip to Content
Python: Master the Art of Design Patterns
book

Python: Master the Art of Design Patterns

by Dusty Phillips, Chetan Giridhar, Sakis Kasampalis
September 2016
Intermediate to advanced
775 pages
18h 22m
English
Packt Publishing
Content preview from Python: Master the Art of Design Patterns

Unit testing

Let's start our exploration with Python's built-in test library. This library provides a common interface for unit tests. Unit tests focus on testing the least amount of code possible in any one test. Each one tests a single unit of the total amount of available code.

The Python library for this is called, unsurprisingly, unittest. It provides several tools for creating and running unit tests, the most important being the TestCase class. This class provides a set of methods that allow us to compare values, set up tests, and clean up when they have finished.

When we want to write a set of unit tests for a specific task, we create a subclass of TestCase, and write individual methods to do the actual testing. These methods must all start ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python for Programmers

Python for Programmers

Paul Deitel, Harvey Deitel
Head First Design Patterns, 2nd Edition

Head First Design Patterns, 2nd Edition

Eric Freeman, Elisabeth Robson
Fluent Python

Fluent Python

Luciano Ramalho

Publisher Resources

ISBN: 9781787125186Purchase Link