Book Image

Daniel Arbuckle's Mastering Python

By : Daniel Arbuckle
Book Image

Daniel Arbuckle's Mastering Python

By: Daniel Arbuckle

Overview of this book

Daniel Arbuckle's Mastering Python covers the basics of operating in a Python development environment, before moving on to more advanced topics. Daniel presents you with real-world solutions to Python 3.6 and advanced-level concepts, such as reactive programming, microservices, ctypes, and Cython tools. You don't need to be familiar with the Python language to use this book, as Daniel starts with a Python primer. Throughout, Daniel highlights the major aspects of managing your Python development environment, shows you how to handle parallel computation, and helps you to master asynchronous I/O with Python 3.6 to improve performance. Finally, Daniel will teach you the secrets of metaprogramming and unit testing in Python, helping you acquire the perfect skillset to be a Python expert. Daniel will get you up to speed on everything from basic programming practices to high-end tools and techniques, things that will help set you apart as a successful Python programmer.
Table of Contents (13 chapters)

Unit Testing

In the previous chapter, we saw various approaches to metaprogramming and programmable syntax in Python. In this chapter, we're going to take a look at the ideas behind unit testing, then move on to several test automation tools we can use to make our testing easier and more useful. We'll focus on what unit testing is, and the ideas that motivate it. We'll also discuss Python's standard unittest package and how it works.

Finally, you'll learn how to use unittest.mock to control the environment that your test code will run in so that the test will remain focused on making sure one thing works properly.

In this chapter, we'll cover the following topics:

  • Understanding the principle of unit testing
  • Using the unittest package
  • Using unittest.mock
  • Using unittest's test discovery
  • Using nose for unified test discovery and reporting
...