0
Assertions & Edge Cases1 / 4

CRASH COURSE

Assertions & Edge Cases

An assertion checks a condition and raises AssertionError when it is false. It is useful for small tests, not validation of untrusted input.

  • A good test covers normal inputs and boundaries. For a passing threshold of 60, test 59, 60, and 61.
  • A failing test shows a mismatch, not automatically where the bug is. Keep tests specific so the wrong behavior is easy to identify.
def passes(score):
    return score >= 60
assert passes(60) is True
assert passes(59) is False
print("Tests passed")