O'Reilly logo

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

Hands-On Test Driven Development with Python

Video Description

Apply the practices of Test-Driven Development using the PyTest framework to easily create your unit tests

About This Video

  • Provides an overview and best practices of Unit Testing.
  • See practical applications and the best practices in Test-Driven Development
  • Provides instruction on the PyTest python unit testing framework and unittest.mock mocking library as well as how to use these tools in several popular Python Integrated Development Environments (IDEs)

In Detail

Do you want to be one of the core developers at your company—the person that everyone wants on their team, and who can deliver new features that work on time? Unit Testing and Test-Driven Development (TDD) are key disciplines that can help you achieve that goal.

In this video tutorial, you’ll learn about the PyTest testing library and how it’s used to write unit tests in Python. You’ll also set up some common Python development environments to use PyTest. You’ll create isolated test environments with Test Doubles and learn how to implement and use them with unittest.mock. Moving on, you’ll get to know some of the best practices in Unit Testing and TDD and get some hands-on experience with programming by implementing unit tests using TDD in Python.

By the end of this course, you’ll be able to apply the practices of Unit Testing and TDD on a daily basis to radically increase the quality of your code and help you and your company achieve your goals faster than ever before.

All the code and supporting files for this course are available on Github at https://github.com/PacktPublishing/-Hands-on-Test-Driven-Development-with-Python

Table of Contents

  1. Chapter 1 : Overview and Setting Up Your Development Environment
    1. The Course Overview 00:02:17
    2. Overview of Unit Testing and TDD Practices and How They Help You Write Better Code Faster 00:07:40
    3. Simple Unit Testing and TDD Coding Session 00:10:17
    4. Creating Python Virtual Environments to Help Manage Your Python Projects 00:05:48
    5. Setting Up PyTest in PyCharm 00:03:25
    6. Setting Up PyTest in Eclipse 00:03:59
  2. Chapter 2 : PyTest Framework Supporting Functional Testing
    1. Introduction of PyTest Framework 00:02:16
    2. Test Discovery Function 00:02:18
    3. XUnit Style Setup and Teardown 00:04:44
    4. Test Fixtures Environment 00:08:22
    5. Assert Statements and Exceptions 00:03:25
    6. PyTest Command Line Arguments 00:04:08
  3. Chapter 3 : Hands-On Example - Implementing a Checkout Cart with TDD
    1. Setting Up a Checkout Cart and the 1st Test Case 00:04:12
    2. Add Items, Add Item Prices, and Calculate the Total 00:06:00
    3. Add Multiple Items and Calculate Total 00:03:44
    4. Add and Apply Discounts 00:13:42
    5. Throw Exception When Adding an Item with No Price 00:02:34
  4. Chapter 4 : Creating an Isolated Test Environment with Test Doubles
    1. Test Doubles and the unittest.mock Framework 00:07:10
    2. Unittest.mock - Mocking the File System Examples 00:11:46
    3. Unittest.mock - Mocking an Abstract Interface 00:05:18
    4. Unittest.mock - Mocking a Network Connection 00:05:15
    5. Adding Code to Checkout Cart to Read Prices from a File 00:07:33
  5. Chapter 5 : Unit Testing and TDD Best Practices
    1. Unit Testing and TDD Best Practices 00:03:33
    2. Hands On Example of Applying Best Practices 00:03:04
    3. Overview of Code Coverage and PyTest.cov 00:02:16
    4. PyTest.cov Hands On Example with Simple Test Cases 00:03:31