Repository navigation
fix(level7): final quality batch — meaningful tests, Ruff gate, hygiene - #68
Merged
Merged
Conversation
- M08 check.py: the checker only confirmed SyncWorker was imported, no
time.sleep() was used, and pytest passed — a suite of six
`assert True` tests satisfied all three. Added a mutation gate with six
single-behavior mutants against task/jobs.py's InMemoryJobRepository
and task/workers.py's SyncWorker (new job not pending, submit never
completes, exception swallowed, result not stored, two jobs sharing
state, unknown job fabricated instead of None) — one per behavior the
README's test table requires. Verified against two structurally
different correct suites (different fixture layout, names, assertion
style) and both the all-tautological and partial-tautological fakes;
deterministic across 3 repeated runs with byte-identical restores.
- M05 check.py: the API integration check only asserted job status was
"completed", never inspected the result — a worker that marks the job
completed but writes `{"fake": True}` passed. Added a check that
result.total_battles matches the request's battle count exactly
(deterministic) and hero_wins + monster_wins sums to the same count
(not exact values, since individual battle outcomes are random).
- M01 check.py: time_tournament() could return a result shaped correctly
without ever calling the service. Added a spy that wraps (not
replaces) _svc.simulate_tournament, confirming it was actually called
and with the requested battle count passed through — not hardcoded.
- P03 check.py: added a Gate 12 running `ruff check api/ tests/` — the two directories that actually contain student-written code in this boss fight (main.py/dependencies.py/schemas.py/jobs/rpg are pre-wired and untouched by the student). Scoped there after confirming the correct reference solution is clean under that scope. A real lint violation in student-owned code now fails the boss fight; an out-of-scope violation (e.g. in jobs/jobs.py) does not. README gets a one-line closing note pointing at the same command — no new lesson, no Mypy/Pyright/coverage/CI. - P03: added data/jobs/.gitignore (*.json, keep .gitkeep) — confirmed empirically that a real `cli.py start` run creates a job file there; with the ignore rule in place the file still gets created but `git status` stays clean, matching the pattern already used for session-file directories elsewhere in the course. - M06 README: reworded "multiple threads on one CPU core don't run in parallel because the GIL..." — the "on one CPU core" framing was redundant/confusing (the GIL constraint isn't about core count). Now: "for CPU-bound pure-Python work, the GIL prevents multiple threads in the same process from running Python bytecode in parallel." Same meaning, no new material (free-threading/C-extension nuance) added.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second and final targeted-rework batch for Level 7, scoped to exactly 6 items from the full-level audit. No changes to M02/M03/M04/M06 checker/M07 checker-or-README/P01/P02/
ProcessPoolTournamentWorker/the P03 CLI contract from Batch 1/seeding/HTTP 425/any new concurrency concepts.check.py: replaced the structural-only check (SyncWorker imported, notime.sleep, pytest passes) with a 6-mutant behavioral gate againstInMemoryJobRepository/SyncWorker— one mutant per behavior in the README's test table.check.py: the API integration check now verifiesresult.total_battlesmatches the request exactly andhero_wins + monster_winssums correctly — not just that status is"completed".check.py: added a spy wrapping (not replacing)_svc.simulate_tournamentto confirmtime_tournament()actually calls it with the real battle count, instead of just shaping a plausible-looking dict.check.py: added a Gate 12 runningruff check api/ tests/— the two directories that actually contain student-written code in this boss fight.data/jobs/.gitignore(*.json/!.gitkeep) after confirming empirically that real CLI usage creates job files there.README.md: reworded the slightly-off "multiple threads on one CPU core don't run in parallel because the GIL..." sentence to drop the redundant "on one CPU core" framing, without adding new material.Test plan
assert True→ FAIL; 1 real + 5 tautologies → FAIL; mutation gate deterministic across 3 runs with byte-identical file restores{"fake": True}result → FAIL; repository/JsonJobRepository/SyncWorker unit tests unaffectedn) → FAILapi/routers/tournaments.py→ FAIL; unrelated violation injected into providedjobs/jobs.py(out of scope) → does not blockcli.py startrun creates a job JSON file indata/jobs/;git status --shortstays cleantools/author_check.py→ 727 checks passed, 0 errorstools/course_status.py→ runs clean__pycache__, no.pytest_cache, no unintended job files, working tree clean except the intended patch🤖 Generated with Claude Code