Packt

Python Testing with pytest: Reliable, Maintainable Code

Packt

Python Testing with pytest: Reliable, Maintainable Code

Included with Coursera PlusLearn more

Gain insight into a topic and learn the fundamentals.
Beginner level

Recommended experience

3 hours to complete
Flexible schedule
Learn at your own pace
Gain insight into a topic and learn the fundamentals.
Beginner level

Recommended experience

3 hours to complete
Flexible schedule
Learn at your own pace

What you'll learn

  • Write clear and maintainable tests with pytest

  • Organize scalable test suites for Python projects

  • Build reusable setup and teardown with fixtures

Details to know

Shareable certificate

Add to your LinkedIn profile

Recently updated!

December 2026

Assessments

8 assignments

Taught in English

See how employees at top companies are mastering in-demand skills

 logos of Petrobras, TATA, Danone, Capgemini, P&G and L'Oreal

There are 7 modules in this course

This module introduces the course objectives and provides a practical guide to setting up a Python development environment with pytest. Learners will gain foundational knowledge on how to prepare their workspace and begin writing reliable tests.

What's included

2 videos1 assignment

This module introduces learners to the fundamentals of writing and organizing tests using pytest. It covers creating assertions, structuring test files, and validating specific behaviors and exceptions in code.

What's included

4 videos1 assignment

This module teaches how to create and manage reusable test setup and teardown code using pytest fixtures. It covers the differences between function- and module-scoped fixtures and how to efficiently share test resources. Learners will gain practical skills to write cleaner, more maintainable tests.

What's included

4 videos1 assignment

This module teaches how to enhance test efficiency and maintainability using parameterisation, skipping, and expected failure handling. Learners will understand how to organise tests with custom markers and manage test execution based on conditions.

What's included

5 videos1 assignment

This module covers the fundamentals of mocking in testing, focusing on how to isolate and replace dependencies using tools like monkeypatch and MagicMock. Learners will gain practical skills in verifying function calls, simulating different execution paths, and choosing the right mocking strategies for their test scenarios.

What's included

6 videos1 assignment

This module teaches learners how to generate, interpret, and enforce test coverage reports using pytest-cov. It covers the differences between line and branch coverage, identifies untested code, and shows how to set up consistent test configurations across environments.

What's included

5 videos1 assignment

This module provides a comprehensive review of the pytest workflow and offers actionable strategies for maintaining and improving automated test suites. Learners will gain insights into best practices for test reliability and efficiency. It serves as a practical guide for continuing testing efforts after initial setup.

What's included

1 video2 assignments

Instructor

Packt - Course Instructors
Packt
2,690 Courses795,495 learners

Offered by

Packt

Why people choose Coursera for their career

Felipe M.

Learner since 2018
"To be able to take courses at my own pace and rhythm has been an amazing experience. I can learn whenever it fits my schedule and mood."

Jennifer J.

Learner since 2020
"I directly applied the concepts and skills I learned from my courses to an exciting new project at work."

Larry W.

Learner since 2021
"When I need courses on topics that my university doesn't offer, Coursera is one of the best places to go."

Chaitanya A.

"Learning isn't just about being better at your job: it's so much more than that. Coursera allows me to learn without limits."

What brings you to Coursera today?

Frequently asked questions