Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

09-defensive.md: Incorrect Error blocks for some assert statements #765

Open
Iain-S opened this issue Nov 27, 2019 · 4 comments
Open

09-defensive.md: Incorrect Error blocks for some assert statements #765

Iain-S opened this issue Nov 27, 2019 · 4 comments

Comments

@Iain-S
Copy link
Contributor

@Iain-S Iain-S commented Nov 27, 2019

Problem description

In the episode on defensive programming, under the "Test-Driven Development" heading, we use assert like so:

assert range_overlap([ (0.0, 1.0) ]) == (0.0, 1.0)

The error block below this code shows an AssertionError. In fact, we get a NameError as range_overlap is not yet defined. This happens again a little further down the page.

Proposed solution

Run the Python assert statements under the TDD heading. Copy the NameError outputs and use them to replace the AssertionErrors, where appropriate.

@ldko

This comment has been minimized.

Copy link
Contributor

@ldko ldko commented Dec 2, 2019

@Iain-S you are correct, running that assert statement before range_overlap is defined does result in a NameError: name 'range_overlap' is not defined rather than an AssertionError. I think your solution makes sense. What do you think @maxim-belkin @annefou ?

@annefou

This comment has been minimized.

Copy link
Contributor

@annefou annefou commented Dec 2, 2019

Yes I like your solution. Thanks.

@maxim-belkin

This comment has been minimized.

Copy link
Contributor

@maxim-belkin maxim-belkin commented Dec 2, 2019

I concur. It looks like someone did def range_overlap(*args): pass (or something like that) before writing the episode.

Thanks for spotting this, @Iain-S!

@ldko

This comment has been minimized.

Copy link
Contributor

@ldko ldko commented Dec 11, 2019

@Iain-S would you be willing to submit a PR with your proposed solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.