Objective & prerequisites
Write a test whose failure would change your confidence in the result. Prerequisites: basic Python expressions and files; use a disposable local practice folder and fictional data. This shared workshop complements the existing data/AI tracks and does not create a second progress system.
Understand the concept
A useful test compares observed behavior with independently established expectations. A test that repeats the same implementation formula can reproduce the same mistake. Choose a small fixture whose answer can be checked by hand, and test meaningful boundaries: empty population, duplicates, malformed fields and unsupported values.
Worked example
The positive control has two unique rows worth 30000 and 40000 cents. Their total is 70000. Rejection tests establish that duplicate IDs and boolean amounts are not silently accepted. These tests prove the stated cases, not all possible correctness.
python3 foundation_labs.py -vTry it yourself
Run the full suite. Write an additional test for a negative amount and one for an empty list; explain the difference between valid emptiness and unavailable data. Record your prediction before running the supplied reference, then compare the observed result and explain any difference.
Worked solution
A negative amount is rejected by this contract. An empty list returns 0 under the current function, but upstream completeness must establish whether it is a real empty population. No fixture can prove all future source behavior.
Knowledge check
Does passing one happy-path test establish production readiness? Try answering without rereading the example.
Check and explain
No. It is bounded evidence for one behavior; validation, failure policy and operating checks remain separate.
Mini-project, mistakes & handover
Produce a short README with the question, exact local command, input meaning, checks and actual results. Include one failure case and its explanation. Never silently turn an exception into a passing result. Mark simulated behavior explicitly, credit the supplied teaching code and identify your own contribution. These activities are unsaved self-practice, not certification.
Authoritative reference
— consulted for the underlying interface/concept. The lesson and fictional examples are original teaching material. Python reference tested with 3.12; designed for 3.10+. Git lab requires Git 2.28+.
Try the activity before reading its reference. Keep your sources, commands and assumptions with your work. Companion activities are unsaved self-practice and do not award a certificate or change lesson progress.