CodeVetter · Repo Unpack · Testing signals
TheAlgorithms/Python
The dominant test mechanism is doctests: pytest runs with --doctest-modules across the entire repo, and CONTRIBUTING/AGENTS require every function to carry passing doctests. A minority of modules have real pytest test files — either colocated (maths/test_*.py) or in per-domain tests/ subdirectories (data_structures, graphs, knapsack, geometry, divide_and_conquer, file_transfer) plus a top-level tests/test_sorts.py battery. Project Euler has a dedicated hashed-answer oracle. Coverage is reported but project_euler is excluded; many files are excluded from the 3.14t run entirely via --ignore flags.
- pytest config sets --doctest-modules, --durations=10, --showlocals globally, so every docstring example in every .py file is executed as a test in CI.
- tests/test_sorts.py is a shared contract harness: it parametrizes ~20 general-purpose comparison sorts against a common battery and documents which sorts are deliberately excluded (counting/radix/pigeon integer-only, stalin/wiggle not fully sorting, etc.).
- Dedicated pytest files exist in pockets: data_structures/{hashing,kd_tree,suffix_tree}/tests/, graphs/tests/, knapsack/tests/, geometry/tests/, divide_and_conquer/tests/, file_transfer/tests/, and colocated maths/test_*.py — most of the repo relies solely on doctests.
- scripts/validate_solutions.py is itself a pytest module: test_project_euler is parametrized over discovered solution paths and asserts the SHA-256 of str(solution()) matches the stored digest, so Euler correctness is verified without exposing plaintext answers.
- The build runs pytest under pytest-run-parallel with --iterations=8 --parallel-threads=auto --ignore-gil-enabled on free-threaded 3.14t, actively probing thread-safety of pure-Python algorithms while tolerating GIL-re-enabling wheels.
- Coverage is collected (--cov=. with term-missing report) but project_euler/* and .env/* are omitted from the report; there is no coverage threshold gate.
- Thirteen paths are excluded from the test run via --ignore flags — including the whole digital_image_processing/ tree, project_euler/ (tested in its own workflow), and network-dependent web_programming files — so 'CI green' does not mean those files ran.
- Doctest conventions include exception tests (doctest: +IGNORE_EXCEPTION_DETAIL for TypeError on mixed-type input) and randomized-sample assertions (random.sample inputs compared to sorted()), which make doctests double as property-ish tests.
- Live-network tests exist: current_stock_price.py's doctests call stock_price('GOOG') expecting a float-parseable string and 'EEEE' expecting an error string — inherently flaky and excluded from CI.
- Static checks act as tests: ruff.yml gates on `ruff check`, pre-commit runs ruff-format/codespell/validate-filenames/uv-lock, and ty runs informationally — no unit-test framework other than pytest+doctest is used.
- project_euler.yml runs pytest --doctest-modules --cov=project_euler/ only on PRs touching Euler paths (plus daily cron), so Euler doctests are validated separately from the main suite.
- There is no conftest.py anywhere in the repo — no shared fixtures; each test file is self-contained, consistent with the one-file-per-algorithm contribution model.