How to build a unit testing library from scratch?
summary
Builds a minimal testing library in Python that reproduces pytest features: a test runner that discovers and calls test functions with try/except and simple reporting, a raises context manager implemented via __enter__/__exit__, a parameterize decorator that loops subtests, and fixtures including yielding fixtures detected by checking for generators. Notes that pytest itself is ~130k lines with ~5,000 PRs; implements decorators, context managers, eval, generators and live-codes fixes — the demo mostly works after iterative bug fixes and prints tracebacks.
AI-written summary · about
chapters (10)
- 0:00Introduction
- 1:05Build your own library
- 3:33Reverse engineering pytest
- 4:37Building the test runner
- 8:30Expected exceptions with raises
- 11:43Parameterized test cases
- 14:54Designing fixtures
- 20:57Debugging fixtures
- 22:53Final demo and next steps
- 23:56Q&A
related talks
27mWhy I use py.test and maybe you should too
38mTesting for the Terrified: How to Write Tests, Conquer Guilt, and Level Up
33mUnit Testing with Pytest
27mPyTest
32mpytest for unittesters
03h 02mdef test_crash_course_with_pytest()
28mEgad! How Do We Start Writing Better Tests?
02h 13mPython Unit Testing with Pytest and Mock
