For every algorithmic change (and every public function/class), require automated tests that lock in both correctness and failure modes.
Minimum standard:
doctest.testmod() in __main__).Example pattern (doctest with edge + failure):
def interpolation_search(sorted_collection: list[int], item: int) -> int | None:
"""
>>> interpolation_search([1, 2, 3, 4, 5], 2)
1
>>> interpolation_search([1, 2, 3, 4, 5], 6) is None
True
>>> interpolation_search([], 1) is None
True
"""
...
if __name__ == "__main__":
import doctest
doctest.testmod()
This standard directly prevents regressions (new validation rules, edge-case fixes, and invariants) and makes behavior verification repeatable and reviewable.
Enter the URL of a public GitHub repository