# Ignore Early-Canceled Tests Example
URL: /examples/ignore-early-canceled-tests
The upstream ignore_early_canceled_tests.py example — subclass OutputToJSON to skip writing records for tests aborted (Ctrl-C) before an operator entered a DUT ID, using default_dut_id.
A station that waits for a barcode scan produces a useless record every time someone presses Ctrl-C at the prompt. This example filters those out in the output callback. Based on `examples/ignore_early_canceled_tests.py`.
Press Ctrl-C *after* entering a DUT ID and the record is written, because the abort then carries information about a real unit.
An output callback is any callable taking a `TestRecord`. Subclassing the built-in keeps its file-pattern handling and lets you add a condition in `__call__`. Custom output →
Set when the run ends on `KeyboardInterrupt` (SIGINT). Other exceptions give `ERROR` and are kept — they may be worth debugging. Test outcomes →
A recognisable sentinel instead of the default `UNKNOWN_DUT`, so the callback can tell "never scanned" from "scanned, then aborted". Test Options →
OpenHTF's console helper; respects the CLI colour settings and does not interleave badly with the logger.
The same shape filters records for any reason — skip uploads for `station_id == 'dev-bench'`, write `FAIL` records to a second directory, or add a retry around a network upload. TofuPilot's `upload()` callback can be wrapped the same way. Output Callbacks →