Guide 5 · Foundations

Testing and Packaging

pytest, virtual environments, project layout, and running the suite on every push.

Complete 10 notebooks 10 written

Before this guide: Python from the Start, and Object-Oriented Python.

The notebooks

Open in Colab runs a notebook in your browser, and Read shows it on GitHub without running it. Every notebook runs on its own, and the answers to its exercises are in a separate notebook, linked as Solutions.

1Why TestThe bug you are going to reintroduce next weekOpen in ColabReadSolutions
2Your First Testpytest, plain assert, and running the suiteOpen in ColabReadSolutions
3Test StructureArrange, act, assert, and one behavior per testOpen in ColabReadSolutions
4FixturesSetup without repetition, and scopeOpen in ColabReadSolutions
5ParametrizeThe same test over many inputs, reported separatelyOpen in ColabReadSolutions
6Testing Failurepytest.raises, and asserting that the right thing went wrongOpen in ColabReadSolutions
7Virtual Environmentsvenv, why it exists, and the tutorial that broke without oneOpen in ColabReadSolutions
8Requirements and PinningRecording an environment somebody else can reproduceOpen in ColabReadSolutions
9Project Layoutsrc, imports that work from anywhere, and the editable installOpen in ColabReadSolutions
10Continuous IntegrationRunning the suite on every push, and reading a failed runOpen in ColabReadSolutions