Book Image

The Python Apprentice

By : Robert Smallshire, Austin Bingham
Book Image

The Python Apprentice

By: Robert Smallshire, Austin Bingham

Overview of this book

Experienced programmers want to know how to enhance their craft and we want to help them start as apprentices with Python. We know that before mastering Python you need to learn the culture and the tools to become a productive member of any Python project. Our goal with this book is to give you a practical and thorough introduction to Python programming, providing you with the insight and technical craftsmanship you need to be a productive member of any Python project. Python is a big language, and it’s not our intention with this book to cover everything there is to know. We just want to make sure that you, as the developer, know the tools, basic idioms and of course the ins and outs of the language, the standard library and other modules to be able to jump into most projects.
Table of Contents (21 chapters)
Title Page
Credits
About the Authors
www.PacktPub.com
Customer Feedback
Preface
12
Afterword – Just the Beginning

Chapter 10. Unit testing with the Python standard library

When we build programs of even minor complexity, there are countless ways for defects to creep into our code. This can happen when we initially write the code, but we're just as likely to introduce defects when we make modifications to it. To help get a handle on defects and keep our code quality high, it's often very useful to have a set of tests that you can run that will tell if you if the code is acting as you expect.

To help make such tests, the Python standard library includes the unittest module. Despite what its name suggests, this module helps with more than just unit testing. It is, in fact, a flexible framework for automating tests of all sorts, from acceptance tests to integration tests to unit tests. Its key feature, like many testing frameworks in many languages, is that it helps you make automated and repeatable tests. With tests like these, you can cheaply and easily verify the behavior of your code at any time.