Go from never having used a coding agent to working productively and safely with one. The learner should understand what an agent is and how it differs from a chat assistant. They should choose a tool, set up a protected first project, describe tasks the agent can do well, and follow and verify its work. They should recover from bad changes, manage context, and plan bigger changes. They should also use tests as the definition of done and run everyday workflows (bug fixes, features, writing tests, codebase exploration, scripts, small tools, refactors). Throughout, they should keep secrets and systems safe and keep their own understanding growing instead of outsourcing it.
What automated tests are and how to run them
card 4 of 6
Reading a run with one failure
builds on: Command output and exit codes, How a code project is laid out
You run `pytest` from the project root (output on the next card). `collected 3 items` means it found 3 tests. In `.F.`, each character is one test: `.` passed, `F` failed. Under FAILURES, pytest names the failing test. The `>` line is the check that failed. The `E` line repeats it with the call replaced by what it actually returned. So `assert 10.0 == 90` means `apply_discount(100, 10)` returned `10.0` where the test expected `90`. The bottom line gives the totals: 1 failed, 2 passed. `echo $?` prints `1`, so the run as a whole failed.
Terms on this card
- test
- A small piece of code that runs part of your program with a known input and checks that the output is what it should be.
- assert
- A statement in a test meaning 'this must be true'. If it is false, the test fails and shows the values involved.
- pytest
- The most common test runner for Python projects. You run it by typing `pytest` in the project root.
- project root
- The top-level folder of a project, the one containing `.git`. Test commands are normally run from here.
- output
- The text a command or program prints when it runs, including results and error messages.
Lesson goal: Explain a test as code that runs your code with known inputs and checks the output. Run a project's test suite with one command and read which tests passed and which failed. ·
the whole lesson