Python Testing and Project Tools
Find the failed alert tests
BOTIE
Examples, experiments and workspace controls
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.
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
- case
- At the limit
- readings_c
- [25]
- expected
- 1
- actual
- 0
- case
- Above the limit
- readings_c
- [28]
- expected
- 1
- actual
- 1
- case
- No readings
- readings_c
- []
- expected
- 0
- actual
- 0
case readings_c expected actual At the limit [25] 1 0 Above the limit [28] 1 1 No readings [] 0 0 - Required result
- case
- At the limit
- readings_c
- [25]
- expected
- 1
- actual
- 0
case readings_c expected actual At the limit [25] 1 0
- Alert tests: inputs and returned counts
- case
- At the limit
- readings_c
- [25]
- expected
- 1
- actual
- 1
- case
- Above the limit
- readings_c
- [28]
- expected
- 1
- actual
- 1
- case
- No readings
- readings_c
- []
- expected
- 0
- actual
- 0
case readings_c expected actual At the limit [25] 1 1 Above the limit [28] 1 1 No readings [] 0 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
- Alert tests: inputs and returned counts
- case
- Several alerts
- readings_c
- [25,26,30]
- expected
- 3
- actual
- 1
- case
- Below the limit
- readings_c
- [18]
- expected
- 0
- actual
- 0
case readings_c expected actual Several alerts [25,26,30] 3 1 Below the limit [18] 0 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.