Autoplay
Autocomplete
Previous Lesson
Complete and Continue
The Complete pytest Course
Course Downloads
Welcome + Introduction (5:37)
Using Teachable to View the Course (5:25)
Source code
Community Access
Part 1: Primary Power
Part 1: Primary Power
Chapter 1: Getting Started with pytest
Intro (0:23)
Installing pytest (3:18)
Our first tests (0:53)
Running pytest (5:21)
Test discovery (2:11)
Test outcomes (4:54)
Chapter 2: Writing Test Functions
Intro (3:40)
Installing cards (3:01)
Playing with cards (3:10)
The cards.Card dataclass (4:34)
Writing Knowledge-Building Tests (4:41)
Running Tests (1:32)
Check Your Setup (2:13)
Bonus: Running Tests in PyCharm (2:45)
Using assert Statements (6:25)
Failing with pytest.fail() and exceptions (3:11)
Writing Assertion Helper Functions (2:58)
Testing for Expected Exceptions (5:25)
Structuring Test Functions (2:54)
Grouping Tests with Classes (6:44)
Running a Subset of Tests (5:23)
Bonus: Virtual Environment functions create/activate/exit for bash/zsh (5:38)
Chapter 3: pytest Fixtures
Intro (1:00)
Visualizing Fixtures (3:24)
Testing the cards API (2:02)
Using Fixtures for Setup and Teardown (5:20)
Tracing Fixture Execution with --setup-show and -s (1:30)
Seeing print output with -s (3:34)
Specifying Fixture Scope (4:06)
Sharing Fixtures through conftest.py (2:13)
Finding Where Fixtures are Defined (3:18)
Intermission 1 (1:48)
Using Multiple Fixture Levels (5:40)
Using Multiple Fixtures per Test (5:09)
Intermission 2 (0:35)
Deciding Fixture Scope Dynamically (3:46)
Using autouse Fixtures (3:38)
Renaming Fixtures (2:35)
Chapter 4: Builtin Fixtures
Intro (1:54)
Using tmp_path and tmp_path_factory (8:23)
Using capsys (4:23)
Output capture with Typer (2:42)
Disabling output capture with capsys (2:54)
The problem with a live db (2:39)
Cards internals (1:47)
Looking at monkeypatch docs (1:10)
Patching get_path (2:40)
Patching pathlib.Path.home (3:47)
Patching an environment variable (0:46)
Design for Testability (1:57)
Chapter 5: Parameterization
Intro (0:24)
Running "cards finish" on the Command Line (1:25)
Looking at the "finish()" API Function (0:33)
Testing Without Parametrize (3:51)
Combining Tests with a Loop (1:31)
Parametrizing Functions (3:13)
Only Parametrizing Meaningful Changes (2:04)
Parametrizing Fixtures (3:56)
What is a Hook Function (1:27)
Parametrizing with pytest_generate_tests (4:11)
Using Keywords to Select Test Cases (2:30)
Chapter 6: Markers
Intro (0:40)
Skipping Tests with pytst.mark.skip (3:57)
Skipping Tests Conditionally with pytst.mark.skipif (4:08)
Expecting Tests to Fail with pytest.mark.xfail (8:03)
Bad Reasons to Use xfail (1:11)
Selecting Tests with Custom Markers (5:17)
Marking Files, Classes, and Parameters (3:42)
Running marked tests with -m (1:24)
Using and, or, not, and Parentheses with Markers and -m (2:36)
Being Strict with Markers (2:51)
Listing Markers with --markers (1:16)
Combining Markers with Fixtures (8:01)
Part 2: Working with Projects
Part 2: Working with Projcts
Chapter 7: Strategy
Intro (0:54)
Determining Test Scope (1:32)
Considering Software Architecture (0:35)
Evaluating the Features to Test (1:39)
Creating Test Cases (0:45)
Writing a Test Strategy (1:20)
Cards Example: Scope, Architecture, and Prioritizing Features (3:09)
Cards Example: Creating Test Cases (4:41)
Cards Example: Writing a Test Strategy (0:55)
Cards Example: From Test Cases to Test Code (4:59)
Cards Example: Running the Tests (0:54)
Chapter 8: Configuration Files
Intro (2:19)
Determining a Root Directory (1:57)
Saving Settings and Flags in pytest.ini (5:27)
Using tox.ini, pyproject.toml, or setup.cfg in place of pytest.ini (4:11)
Avoiding Test File Name Collision with __init__.py (5:08)
Chapter 9: Coverage
Intro (1:13)
Measuring Code Coverage with `pytest-cov` (3:02)
Measuring Code Coverage with `coverage` Directly (2:05)
Specifying Multiple Equivalent Source Paths in `.coveragerc` (1:59)
Generating HTML Reports (6:00)
Excluding Code from Coverage (1:57)
Adding the Missing Test Cases (2:48)
Beware of Coverage-Driven Development (2:45)
Running Coverage on Tests (2:34)
Running Coverage on a Directory (2:14)
Running Coverage on a Single File Script (3:48)
Chapter 10: Mocking
Intro (2:12)
What Are We Mocking? Isolating the Cards CLI (4:10)
Testing with Typer + shlex + cards_cli (5:22)
Mocking an Attribute (4:26)
Mocking a Class and Methods (6:56)
Using a Fixture for Mocking (2:30)
Using autospec to Keep Mocks and API Synchronized (3:54)
Making Sure Functions Are Called Correctly (3:42)
Creating Error Conditions (2:12)
Running Coverage + Coverage Exclusion (4:04)
Read the Docs (0:22)
Mocks Don't Test Behavior (1:22)
Testing at Multiple Layers to Avoid Mocking (4:10)
Using Plugins to Assist Mocking (1:03)
Chapter 11: tox and Continuous Integration
Intro (1:53)
Setting Up tox (6:03)
Running tox (2:22)
Testing Multiple Python Versions (2:36)
Running tox Environments in Parallel (1:11)
Adding a Coverage Report to tox (1:15)
Specifying a Minimum Coverage Level (1:10)
Passing pytest Parameters Through tox (1:31)
Combining pytest.ini and .coveragerc into tox.ini (2:48)
CI: Running tox with GitHub Actions (6:04)
Chapter 12: Testing Scripts and Applications
Intro (1:32)
Testing a Python Script (8:17)
Testing an Importable Python Script (4:30)
Separating Code into src and tests Directories (2:24)
Testing a requirements.txt-based Application (5:05)
Chapter 13: Debugging Test Failures
Intro (2:12)
Setup (4:07)
Writing Tests First (6:39)
First Draft Implementation (3:30)
Debugging with pytest Flags (4:47)
Debugging with pdb (2:36)
Combining tox and pdb (2:23)
Refactoring (4:17)
Note on Code Sample (0:41)
Part 3: Booster Rockets
Part 3: Booster Rockets
Chapter 14: Third-Party Plugins
Exploring the Diversity of pytest Plugins (4:15)
Finding Plugins (2:02)
pytest-repeat: Repeating Tests (3:54)
pytest-xdist: Running Tests in Parallel (3:55)
pytest-randomly: Randomizing Test Order (4:07)
Chapter 15: Building Plugins
Introduction (1:54)
Building a Local conftest Plugin (2:41)
Creating an Installable Plugin (15:09)
Testing Plugins with pytester (7:13)
Testing Multiple Python Versions with tox (3:30)
Using a src Project Layout (2:10)
Publishing Plugins and Further Information (1:48)
Chapter 16: Advanced Parametrization
Introduction (1:19)
Creating Custom Identifiers (8:04)
Parametrizing with Dynamic Values (2:30)
Using Multiple Parameters (3:30)
Using Indirect Parametrization (3:23)
Selecting a Subset of Fixture Parameters (1:23)
Creating an Optional Indirect Fixture (2:06)
Teach online with
Design for Testability
Lesson content locked
If you're already enrolled,
you'll need to login
.
Enroll in Course to Unlock