An edge case is an unusual, boundary, or exceptional input or operating condition that may expose incorrect program logic. Testing these cases checks that code handles unexpected values and situations deliberately. section 10.1
Include edge cases when testing:
- Invalid or implausible values, such as a customer age of 500 or an age represented as a string. section 10.1
- Unexpected control-flow conditions, including both outcomes of if-else statements and try/except clauses. section 10.1
- Missing results, such as a database query returning no data, and inputs that could cause model or function failure. section 10.1 section 10.4
Treat edge-case tests as part of broader test coverage. Covering many ordinary paths is not enough if important branches, error-handling paths, or unusual inputs remain unexecuted. section 10.4
A practical test target
For a customer-age feature, test a normal numeric age, a string value, and an implausible value such as 500. Then verify that the intended validation or handling logic runs rather than allowing an unnoticed failure. section 10.1
Listing 10.21 Use the coverage library to generate an HTML report showing what lines were not executed during testing.
coverage html ch10/test_full_pipeline.py #1
Generate an HTML coverage report to find lines that no test executes; use the uncovered lines to identify missing edge-case tests. section 10.4












