December 2017
Beginner
412 pages
10h 8m
English
The first function that we’ll test is above_freezing from Testing Your Code Semiautomatically:
| | def above_freezing(celsius: float) -> bool: |
| | """Return True iff temperature celsius degrees is above freezing. |
| | |
| | >>> above_freezing(5.2) |
| | True |
| | >>> above_freezing(-2) |
| | False |
| | """ |
| | |
| | return celsius > 0 |
In that section, we ran the example calls from the docstring using doctest. But we’re missing a test: what happens if the temperature is zero? In the next section, we’ll write another version of this function that behaves differently at zero and we’ll discuss how our current set of tests is incomplete.
Before writing our testing code, we must decide ...
Read now
Unlock full access