Lesson 113: pytest fixtures and parametrization
Focus
Assume a reviewer executes this verbatim: Advanced drills pytest fixtures and parametrization; spin token 974415 makes this page unlike its neighbours.
Key ideas
- Angle
Advanced: micro cadence3mixespytest fixtures and parametrization; spin31315. - Ritual: Sketch control flow as ASCII before trusting output.
- Guardrail: separate demo-trick from shipping discipline verbally.
Example (LESSON_UID = "advanced-113")
# Advanced drill L113 topic-11 micro-2 pattern-10
LESSON_UID = "advanced-113"
spin_a, spin_b, spin_c = 168, 535, 838
def gate(v):
if v < spin_a + 2:
return "low", v ** 2
if v > spin_b + 113:
return "high", v // max(1, 2 + 1)
return "mid", v + spin_c
cand = [6, 16, 338]
for candidate in cand:
lbl, val = gate(candidate)
print(candidate, lbl, val)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-113.txt"
snap = [126, 300, 474, 648, 822]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (838 + 131))
import asyncio
async def finalize(seed, spin):
await asyncio.sleep(0)
blend = (seed * 131 + 11 * (11 % 997) + 2 * (2 % 853) + spin) % 900001
return blend
async def harness(loop_seed):
print("async_result", await finalize(loop_seed, 43168))
asyncio.run(harness(26971))
Practice
Practice 8: Shadow one variable purposely to spotlight scope quirks. Literal nudge 8.
Fingerprints
- lesson_uid:
advanced-113 - umbrella band:
pytest fixtures and parametrization(3/10) - lesson_index:
3599