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 5 of 6
A pytest run, one test failing
builds on: Command output and exit codes, How a code project is laid out
Progress is at the top (`[100%]` means all collected tests have run). The failure detail is in the middle and the totals are at the bottom. The last command shows the exit code.
$ pytest
collected 3 items
tests/test_prices.py .F. [100%]
========== FAILURES ==========
_________ test_discount _________
> assert apply_discount(100, 10) == 90
E assert 10.0 == 90
===== short test summary info =====
FAILED tests/test_prices.py::test_discount
===== 1 failed, 2 passed in 0.04s =====
$ echo $?
1
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.
- pytest
- The most common test runner for Python projects. You run it by typing `pytest` in the project root.
- exit code
- A number a command reports when it finishes. 0 means success; anything else means failure.
- command
- A line of text that tells the computer to run a program, typed in a terminal, for example `python src/cart.py`.
- tests
- Small pieces of code that run your program's code and check it gives the expected results.
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