Checking your account

You can read the lesson while its saved answers and constructions load. Learning controls will open once that work is ready.

Python Testing and Project Tools

Find the failed alert tests

Coding challenges

BOTIE

Return the complete rows for tests whose actual count differs from expected. The first result should contain only "At the limit". Read the actual and expected fields, compare their values, then use those decisions to keep the failed rows.
Ready to test
0 passed · 0 failed · 2 not run

An empty floor. Start with the information your machine needs.

Received result

Your answer will arrive here.

Examples, experiments and workspace controls
Live values

Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.

Try your own inputs

Use a copy of the example to try your own data. Keep the problem's assumptions in mind, and predict the effect of a change before checking the output. You can also add another branch to compare two ways of doing the calculation.

Start at an output arrow, then click or drag to an input. Drag empty space to pan. Delete removes a selection. Ctrl/Cmd+Z undoes a change.
Context for this challenge

Return the complete rows for tests whose actual count differs from expected. The first result should contain only "At the limit". Read the actual and expected fields, compare their values, then use those decisions to keep the failed rows.

The alert report runs, but one of its answers changed.

Start with the test rows. A field reader extracts one column; the comparison marks different counts; Keep flagged entries returns the corresponding complete rows.

Examples and results
Alert tests: inputs and returned counts
  1. case
    At the limit
    readings_c
    [25]
    expected
    1
    actual
    0
  2. case
    Above the limit
    readings_c
    [28]
    expected
    1
    actual
    1
  3. case
    No readings
    readings_c
    []
    expected
    0
    actual
    0
Required result
  1. case
    At the limit
    readings_c
    [25]
    expected
    1
    actual
    0
Alert tests: inputs and returned counts
  1. case
    At the limit
    readings_c
    [25]
    expected
    1
    actual
    1
  2. case
    Above the limit
    readings_c
    [28]
    expected
    1
    actual
    1
  3. case
    No readings
    readings_c
    []
    expected
    0
    actual
    0
Required result
[]
Try a fresh construction

This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.

Stuck? Inspect a worked construction

The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.

Assumptions and test precision

These are recorded Python test results. The blocks compare their counts; the coding challenge runs the actual report and its tests. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.

One alert is counted instead of three

This check uses the pieces from “Find the failed tests”.

BOTIE

The report returns one alert for [25,26,30], although all three readings reach the 25 C limit. The below-limit test still returns the expected zero.
Alert tests: inputs and returned counts
  1. case
    Several alerts
    readings_c
    [25,26,30]
    expected
    3
    actual
    1
  2. case
    Below the limit
    readings_c
    [18]
    expected
    0
    actual
    0

Saving your prediction runs your current construction on these inputs and checks the earlier examples too.

Build a construction in the workspace above first. This case will test those pieces.

Which additional input would help expose a mistake in the count?

Keep the input and both counts beside each failure.

These are recorded Python test results. The blocks compare their counts; the coding challenge runs the actual report and its tests.

Continue the courseDependency Injection and Test Doubles →
← Context Managers and Resource Cleanup