Hands-On Test Driven Development with Python

Hands-On Test Driven Development with Python

English | MP4 | AVC 1920×1080 | AAC 48KHz 2ch | 2h 18m | 500 MB

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

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.

This course takes a step-by-step approach, providing an in-depth explanation of TDD and example coding sessions that show you how the tools and practices are actually applied to real-world problems.

What You Will Learn

  • Know how to write better Python code faster using the disciplines of Unit Testing and TDD
  • Use code coverage tools to ensure your unit tests are thoroughly testing all of your production code
  • See the application of Unit Testing and TDD using the PyTest unit testing framework to create your unit tests
  • Set up several popular Python IDEs to run PyTest unit tests and visually show the results in the IDE
  • Get to know the best practices for Unit Testing and TDD and how to apply them
  • Apply an Isolated Test Environment using the unittest.mock library to test your production code in isolation
  • Create Python virtual environments to create isolated Python development environments for each of your projects
Table of Contents

Overview and Setting Up Your Development Environment
1 The Course Overview
2 Overview of Unit Testing and TDD Practices and How They Help You Write Better Code Faster
3 Simple Unit Testing and TDD Coding Session
4 Creating Python Virtual Environments to Help Manage Your Python Projects
5 Setting Up PyTest in PyCharm
6 Setting Up PyTest in Eclipse

PyTest Framework Supporting Functional Testing
7 Introduction of PyTest Framework
8 Test Discovery Function
9 XUnit Style Setup and Teardown
10 Test Fixtures Environment
11 Assert Statements and Exceptions
12 PyTest Command Line Arguments

Hands-On Example – Implementing a Checkout Cart with TDD
13 Setting Up a Checkout Cart and the 1st Test Case
14 Add Items, Add Item Prices, and Calculate the Total
15 Add Multiple Items and Calculate Total
16 Add and Apply Discounts
17 Throw Exception When Adding an Item with No Price

Creating an Isolated Test Environment with Test Doubles
18 Test Doubles and the unittest.mock Framework
19 Unittest.mock – Mocking the File System Examples
20 Unittest.mock – Mocking an Abstract Interface
21 Unittest.mock – Mocking a Network Connection
22 Adding Code to Checkout Cart to Read Prices from a File

Unit Testing and TDD Best Practices
23 Unit Testing and TDD Best Practices
24 Hands On Example of Applying Best Practices
25 Overview of Code Coverage and PyTest.cov
26 PyTest.cov Hands On Example with Simple Test Cases