Real pytest exercises#
Two isolated exercises, one for fixtures and one for parametrize. Each stands on its own; do them in order if you're going through the notes in order, or use one alone as a smaller rep of a single idea before or after the project in ../project/. Neither is required, the same way the project step is the actual test of this module, not these.
Unlike this module's notes, these two files are themselves pytest test files (that's the point, you're writing tests, not reading about them), so they're named test_*.py from the start, and pytest will find them by that name alone.
test_fixture_practice.py, matchingnotes/02-fixtures.md: write a fixture and a test that uses it, against a smallInventoryclass.test_parametrize_practice.py, matchingnotes/03-parametrize.md: write one parametrized test covering several cases of a smallshipping_costfunction.
Each file has its task in a docstring at the top and # your code here markers. Run either one with pytest test_fixture_practice.py (adjust the filename), from this exercises/ folder, once you've filled it in. Running one before you've written anything just reports that pytest collected zero tests, which is expected, not an error.
There's no solutions/ folder for these, the same as the rest of this program: each task is small enough, and each note it matches is short enough, that writing your own version and rereading the note if something doesn't click is the actual exercise.