This repo contains automated tests for the tutorials on reimplementing the module itertools
.
The exercises are taken from my book “The little book of itertools
”.
Follow these instructions if you're attending the PyCon US tutorial “Reimplementing the module itertools
for fun & profit”:
- star the repository (absolutely essential; the Internet will break if you don't!);
- clone the repository locally or download its contents;
- make sure you're running Python 3.10+, but ideally Python 3.12+ (here's how to do it with
uv
); - install the requirements (check the file
requirements.txt
, but all you need ispytest
; with uv, runuv tool install pytest
); and - check everything is right by running
pytest count.py
, which should runpytest
on the filecount.py
; this should show ~20 failing tests.
Make sure you do this before the tutorial, since Wi-Fi at the venue is supposedly subpar.
Each file contains the signature for an itertools
object at the top of the file.
(The signature in the .py
file might not match the full signature of the tool from itertools
. This is on purpose.)
Each file also contains a number of automated tests to check your work.
Once you fill in the signature with your implementation of the tool, you will want to run the automated tests with pytest.
Make sure pytest is installed and then run pytest file_to_test.py
.
For example, once you complete count.py
, you'll run pytest count.py
.