Getting started with pytest Course

Getting started with pytest Course

English | MP4 | AVC 2560×1440 | AAC 44KHz 2ch | 67 Lessons (3h 28m) | 416 MB

This course teaches you to effectively use Python’s most popular and powerful test framework, pytest. pytest is partly so widely used because it’s so fast to get started. However, many people stop with the basics and never learn pytest’s true power.

In Getting started with pytest, you’ll do so much more than just get started. You’ll learn the five super powers of pytest: simple test functions, fixtures, parametrization, markers, and plugins. With this knowledge, you’ll be able to test more effectively and efficiently, whenever you need to write software tests.

What will you learn?
In this course, you will:

  • Build clean, readable, well structured test functions.
  • Utilize fixtures to hold setup, teardown, and test data.
  • Share fixtures between tests and between test files.
  • Trace test execution through tests and fixtures to help debug tests.
  • Use test parametrization to create reams of test cases with a small number of test functions.
  • Identify test parametrizations cleanly with test ids.
  • Learn to skip tests with markers.
  • Run subsets of tests using keywords, markers, test classes, and combinations of these techniques.
  • Expand pytest functionality with pytest plugins.
  • And lots more
Table of Contents

1 Welcome
2 What is pytest?
3 Why pytest?
4 pytest vs. unittest
5 Topics covered
6 The cards app
7 Prerequisites
8 Meet your instructor
9 The companion book
10 Introducing test functions
11 Setting up our test environment
12 Writing our first tests
13 Running the cards application
14 A dataclass called Card
15 Unit testing the Card class
16 Enhanced assert tracebacks
17 Using pytest.fail() and Exceptions
18 Structuring test functions
19 Using test classes
20 Running a subset of tests
21 Introducing test fixtures
22 Using fixtures to pass test data
23 Using fixtures for setup and teardown
24 Tracing execution with –setup-show
25 Testing cards with database setup and teardown
26 Moving setup and teardown into a fixture
27 Specifying fixture scope
28 Naive fix for test order dependency
29 Using multiple fixture levels
30 Sharing fixtures through conftest.py
31 Finding where fixtures are defined
32 Using builtin fixtures
33 Using multiple fixtures per test
34 Review
35 Introducing test parametrization
36 Manually testing “cards finish”
37 Testing without parametrization
38 Combining tests without parametrization
39 Parametrizing functions with two parameters
40 Parametrizing functions with one parameter
41 Stacking function parameters
42 Fixture parametrization
43 Using multiple parametrized fixtures
44 Using keywords to select test cases
45 Using ids for parameter objects
46 Review
47 Introducing markers
48 Skipping tests with pytest.mark.skip
49 Skipping tests conditionally with pytest.mark.skipif
50 Expecting tests to fail with pytest.mark.xfail
51 Selecting tests with custom markers
52 Using -ra to see reasons for all test outcomes
53 Review
54 Introducing pytest plugins
55 Finding plugins
56 Repeating tests with pytest-repeat
57 Running tests in parallel with pytest-xdist
58 Randomizing test order with pytest-random
59 Review
60 Configuration and other non-test files
61 The non-test files in the cards application
62 Common settings in pytest.ini
63 Using pyproject.toml, tox.ini, or setup.cfg
64 Finding information about all possible settings
65 Avoiding test file name collision with __init__.py
66 Review
67 What we learned and where to get more information

Homepage