Testing, Debugging & Reproducibility

Correctness claims need an independent oracle and failures need evidence. This section turns testing, source control and environment capture into one repeatable investigation discipline.

Section 3 of 5 · 8 units · about 28 hours

0/8

By the end you can Resolve one unfamiliar seeded defect with a hypothesis log and regression test, then rebuild and reproduce the result from a clean checkout and recover one displaced Git commit.

Units

Build it

Mini project · about 8 to 12 hours

Test, debug and pin the taskrunner

Make the task runner's correctness and environment reproducible with oracle-based tests and a property that finds a seeded defect. Keep an evidence-first debugging log and a locked environment whose runs write a manifest.

  1. 1Test params_hash against boundary cases and plan against an independent edge-by-edge oracle that also rejects cyclic input, running each test alone, with the Missing Semester code-quality unit test as reference.
  2. 2Seed an order-dependent hashing defect, write the Hypothesis property over same-items different-order inputs that finds it following the Hypothesis quickstart shrinking pattern, pin the shrunk case with @example, then fix the canonical form.
  3. 3Seed order-dependent output that makes a test fail across fresh processes using the Missing Semester run-until-failure script, show a fixed seed only repeats the outcome, then fix the ordering and record failure counts before and after.
  4. 4Seed an off-by-one in a CLI output path and, before touching the code, log competing hypotheses with the observation that would kill each following the Missing Semester merge-sort debugger exercise, then fix it with quoted tool output beside each rejection.
  5. 5Rebuild a regression from history on a branch with a status-coded check script, locate it with git bisect run following the Missing Semester version-control history exercises, and delete and recover a branch tip through git reflog.
  6. 6Write a fail-fast shell entry with quoted arguments, a trapped temporary directory and separate logs checked against the Missing Semester course-shell stream and status exercises, and show it exits cleanly on TERM with no leftovers.
  7. 7Lock the environment, gate on sync plus tests plus typecheck, write a run manifest with commit, config, inputs, seed and outputs, and pass the gate over SSH inside tmux following the Missing Semester SSH, tmux and lockfile exercises.
What you hand in
  • The test suite: oracle and boundary tests, the property with its pinned case, and the flaky test's counts before and after.
  • The debugging log with hypotheses and quoted evidence, and the bisect transcript naming the first bad commit.
  • The shell wrapper transcripts, the lockfile, the one-command gate, two manifests with their diff and the remote transcript.
How to check it
  • Self-grade with the rubric below
How it's graded

Independent oracles

Pass: Each test names its oracle, the plan is checked edge by edge, and every test passes alone.

Great: Each oracle stays independent of the code under test, and a deliberate mutation makes a test fail.

Properties and flakiness

Pass: The property finds the order defect, the shrunk case is pinned, and the flaky test is fixed with counts before and after.

Great: The write-up explains why the shrunk case is minimal and why a pinned seed would hide the flake.

Evidence-first diagnosis

Pass: The log rejects at least two hypotheses with quoted tool output, and bisect names the seeded commit unaided.

Great: Each hypothesis states its killing observation first, and the regression test fails on the found commit.

Locked reproducibility

Pass: A clean checkout reaches a green gate, the wrapper exits as specified with no leftovers, and every run writes a manifest.

Great: Two manifests explain an output difference field by field, and the gate also passes on the remote host.

Resources

  • The Missing Semester of Your CS EducationMIT

    Complete the 2026 lectures on the shell, command-line environment, development tools, debugging and profiling, Git, packaging and shipping code, and code quality. Apply every exercise to the same stage project.

  • pytest documentationpytest

    Use Get Started, fixtures, parametrization, monkeypatch, caplog and temporary paths to build behavior and failure-path tests without order dependence.

  • Hypothesis documentationHypothesis

    Follow the Quick start and property-based testing guides, then generate operation histories and retain the minimized example for one real defect.

  • The Art of DebuggingStas Bekman

    Use the Unix, Python and compiled-code sections during a real seeded defect. Follow the evidence and tiny-reproducer workflow rather than reading the unfinished book front to back.

  • Pro GitGit project

    Use Chapters 2-3 and the sections on debugging, internals and recovery while constructing a history for bisect and recovering a deliberately displaced commit.

  • Stas' Python Cookbook - debugging and testingStas Bekman

    Use Part III and the packaging sections for debugger, traceback, pytest, logging, profiling and clean-environment recipes.

  • AlgoMaster Python - mockingAlgoMaster

    Use the Mocking lesson for unittest.mock: Mock versus MagicMock, patch targets, autospec and the over-mocking trap. The pytest docs remain the reference for fixtures and monkeypatch.