Skip to content

Pytest Output Reader

Run the Pytest Output Reader MicroSim Fullscreen

You can include this MicroSim on your website using the following iframe:

<iframe src="https://dmccreary.github.io/robot-arm/sims/pytest-output-reader/main.html"
        height="642px" width="100%" scrolling="no"></iframe>

Description

Read six real pytest failure messages from the lab's code, each with a bug put in on purpose, and decide which of six causes each one points to. Explore mode explains every cause and the fix it usually needs. Used in Chapter 13.

The six causes are:

  1. The code returns a different value than the test expects
  2. Decimals were compared with exact equality
  3. A fixture is missing or misspelled
  4. The test never created the state that it checks
  5. A check that should have refused did not refuse
  6. Python cannot find the library

Lesson Plan

Grade level: Middle school and up (age 12+). Time: 10 to 15 minutes.

  1. Explore. Press each of the six causes. Read what it means and the fix it usually needs.
  2. Six messages. Choose Six messages in the menu. Each one is a line that pytest printed. Press the cause that it points to. Pressing a button commits your answer. You get one attempt at each, and 5 of 6 is mastery.
  3. Read the clue. Which words in the message gave the cause away? A message such as DID NOT RAISE or not found names the problem almost directly.
  4. Think about it. A failing test does not always mean that the code is wrong. In which of the six messages was the test itself the problem?

The messages were produced by running pytest on a copy of the lab's tests. Pytest starts each line of a failure report with a red E.

Specification

The learning objective, evidence of mastery and content for this MicroSim are specified in Chapter 13: Logging, Testing, Simulation, and ROS 2.