Advanced · Included in Ascent
Join Brightcart, an online shop in Amsterdam, as a test automation engineer. Learn pytest from the ground up: writing and reading tests, testing functions and classes, edge cases and exceptions, fixtures and their scopes, parametrization, markers, temporary files, mocking with unittest.mock and monkeypatch, testing data and business logic, and designing a test suite that stays fast and trustworthy. Your tests run against Brightcart's code with planted bugs, and pass only when they catch them.
You've joined Brightcart, an online shop for home and garden goods in Amsterdam, as a test automation engineer. Femke de Vries, the QA lead, is your mentor; Sam Okoro, a backend developer, writes much of the code you'll test. Every exercise runs real pytest: your tests pass only if they pass on Brightcart's code and catch the bugs planted in copies of it.
What a test is, how pytest finds and runs tests, and how to read what it tells you.
Test functions and classes, cover edge cases and exceptions, and keep tests small and readable.
Share setup with fixtures, control how often they run, clean up after them, and organise them in conftest.py.
Run one test over many inputs, label and select tests with markers, skip and expect failures, and test files safely.
Replace payment providers, mail servers, clocks and dice with stand-ins you control, and keep tests independent.
Test configuration files, reports, dates, discount rules and state machines: the code where business bugs live.
Design test suites that stay fast and trustworthy: factories, coverage, flaky tests, mocking judgement, debugging and hooks.
Ten milestones build a complete, professional pytest suite for Brightcart's shop: users, products, cart, discounts, orders and payments.
Pass every lesson and the capstone, then the 15-question final quiz, to earn your Mastering pytest: Beginner to Advanced certificate with a link anyone can verify.
Learn pytest by catching real bugs: a hands-on course
Learn pytest from your first assert to fixtures, mocking and a full shop test suite. Real pytest runs in your browser, and your tests must catch planted bugs.
Testing with pytest: run, read and write Python tests
How to run pytest, read a failing test, select tests with markers and -k, share setup with fixtures, cover many cases with parametrize, and test exceptions.
pytest fixtures explained: scope, yield, conftest.py and factories
How pytest fixtures work: requesting them, scopes, yield teardown, conftest.py, parametrized and autouse fixtures, and factory fixtures, with real examples.
Mocking in pytest: Mock, patch and monkeypatch explained
Test code that calls payment providers, email, the clock or randomness: Mock, MagicMock, side_effect, where to patch, monkeypatch, and when not to mock.