
Welcome to the course, and how to get the most out of it
Learn how to set up your development environment in order to use pytest
Learn how to write and run basic pytest tests, covering test discovery, assertions, and how to interpret test output.
Learn how tests are organised in a dedicated folder, how pytest discovers tests and source code across a project structure.
Learn how to structure tests so that they focus on one behaviour, making it easy to interpret test results.
Learn how to test for expected exceptions being raised.
Learn how to reduce repetition in order to have simpler, cleaner tests
Learn how tests are isolated and the difference between function- and module-scope fixtures
Learn how module-scope fixtures can be used when tests are resource intensive
Learn how to clean up after tests that create or use external resources
Learn how to remove duplication by with the parametrize marker
Learn how to temporarily exclude a test for a feature that hasn't been implemented yet
Learn how to skip tests based on a condition such as the OS or Python version
Learn how to handle tests that are expected to fail without affecting the rest of the test suite
Learn how to use custom markers to organise your test functions
Learn what mocking is and a simple implementation using built-in monkeypatch
Learn how to manually check to see if a dependency was called using monkeypatch
Learn how different paths through the code under test can be tested with monkeypatch
Learn how to use the MagicMock class for mocking dependencies
Learn which mocking tool to choose when mocking in pytest
Learn how to use the pytest-mock plugin for cleaner mocking code
Learn how to create a test coverage report
Use test coverage reports to find code that isn't covered by the tests
Learn the difference between the default line coverage and branch coverage
Learn how to make the test suite fail if a minimum level of coverage isn't achieved
Learn how to store coverage settings in a configuration file, useful in CI pipelines
Conclusion of the course
Pytest is a modern, popular Python testing framework used to write and run automated tests for Python code. It makes testing simple and scalable, allowing you to create clear tests with minimal boilerplate while supporting advanced features such as fixtures, parameterisation, and mocking.
Pytest helps developers catch bugs early and refactor code with confidence by making automated testing simple and efficient.
Learn how to write, organise, and run automated tests with pytest to build more reliable and maintainable Python applications.
Testing fundamentals and writing your first pytest tests
Organising and structuring test suites
Using fixtures for reusable test setup and teardown
Parameterising tests to cover multiple scenarios
Working with markers to group and control test execution
Mocking and patching dependencies with pytest tools
Testing exceptions and edge cases
Generating and interpreting coverage reports
Enforcing minimum test coverage standards
Configuring pytest and coverage settings for real-world projects
Best practices for writing maintainable and effective tests
Building a complete testing workflow suitable for professional development and CI pipelines
Developing Python applications is far easier and less error-prone when you can quickly verify that your code works as expected using a testing framework like pytest.
Content and Overview
This course is designed for Python developers who want to learn how to write reliable, maintainable code by building a solid foundation in automated testing with pytest. I designed the course for Python developers who want to move beyond manual testing and learn how to build confidence in their code through automated testing.
This course takes you from writing Python code with no tests to confidently building, organising, and maintaining production-ready applications using pytest. Step by step, you’ll learn how to write, structure, and test Python applications using pytest, while applying best practices to build reliable and maintainable code.
Suitable for all Python developers, you'll start by learning the core features of pytest.
You'll learn how to organise your tests the pytest way, and how to work efficiently with it.
At each stage real-world examples are used to show how pytest is used in practical Python development.
Throughout the course, we'll use techniques that you can reuse in all your projects.
All the source code developed in the lectures is available to download.
All the time we'll adhere to industry standards and best practices.
By the end of the course, you’ll be able to confidently write, structure, and run pytest tests to build reliable Python applications.
Complete with all the code shown in the lectures, you'll be able to work alongside the instructor and will receive a verifiable certificate of completion upon finishing the course.
Also, at all times throughout the course you have access to the instructor in the Q&A section to ask for help with any topic related to the course.
Enrol now and start building confidence in your Python code through practical, real-world testing with pytest.