Skip to content

Commit eef9b49

Browse files
committed
CHG: Bring empty function into namespace for tdd
- otherwise assertions fail with NameError Changes to be committed: modified: _episodes/10-defensive.md
1 parent 6f44f71 commit eef9b49

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

_episodes/10-defensive.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,15 @@ Its advocates believe it produces better code faster because:
304304
rather than to find errors.
305305
2. Writing tests helps programmers figure out what the function is actually supposed to do.
306306

307-
Here are three test functions for `range_overlap`:
307+
We start by defining an empty function `range_overlap`:
308+
309+
~~~
310+
def range_overlap(ranges):
311+
pass
312+
~~~
313+
{: .language-python}
314+
315+
Here are three test statements for `range_overlap`:
308316

309317
~~~
310318
assert range_overlap([ (0.0, 1.0) ]) == (0.0, 1.0)
@@ -326,10 +334,9 @@ AssertionError:
326334
{: .error}
327335

328336
The error is actually reassuring:
329-
we haven't written `range_overlap` yet,
330-
so if the tests passed,
331-
it would be a sign that someone else had
332-
and that we were accidentally using their function.
337+
we haven't implemented any logic into `range_overlap` yet,
338+
so if the tests passed, it would indicate that we've written
339+
an entirely ineffective test.
333340

334341
And as a bonus of writing these tests,
335342
we've implicitly defined what our input and output look like:

0 commit comments

Comments
 (0)