DataCareerHub
Explore learning
← Shared foundationsFree companion · 25 minute suggested activity

Test behavior with a known control

Testing & reproducibility · Shared foundation workshop · Write a test whose failure would change your confidence in the result.

Learn → Try → ExplainReviewed 2026-10-15
01

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.

02

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.

03

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 -v
04

Try 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.

06

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.

08

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.

09

Authoritative reference

Read the official 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+.

Make the reasoning yours.

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.

Resume guidance and examples are for learning and preparation only. They do not guarantee interviews, a job offer or employment.

Public registration, payments and new paid enrolment remain disabled. These free resources do not grant access to protected course modules.

Learner dashboard ↗ · Ask a question ↗