Skip to content

bpo-35565: Add detail to assertion failure message in wsgiref#11293

Merged
rhettinger merged 2 commits intopython:masterfrom
csabella:bpo35565
Dec 25, 2018
Merged

bpo-35565: Add detail to assertion failure message in wsgiref#11293
rhettinger merged 2 commits intopython:masterfrom
csabella:bpo35565

Conversation

@csabella
Copy link
Contributor

@csabella csabella commented Dec 23, 2018

Add the header name and value to the assertion failure message for hop-by-hop headers.

https://bugs.python.org/issue35565

Copy link
Contributor

@rhettinger rhettinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core update looks good.

Usually we don't put in a test for the specific wording of an error message. This makes is easier to update in the future.

Also, minor tweaks to error messages usually don't warrant a NEWS blurb (that would result a worse signal-to-noise ratio).

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

"AssertionError: Hop-by-hop header, 'Connection: close',"
" not allowed"
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't simply do .. assertRaise(AssertionError ...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eamanu Thanks for the review and the suggestion. I didn't do this originally to keep it consistent with the other tests (test_simple_validation_error and test_status_validation_errors). But, based on Raymond's review and your comment, I've changed it to just check that an AssertionError is raised.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the assertRaise is poorly written

@eamanu
Copy link
Contributor

eamanu commented Dec 23, 2018

LGTM

@csabella
Copy link
Contributor Author

csabella commented Dec 23, 2018

@rhettinger Thank you for the review. Your explanations are helpful for my learning. I've changed the test to just make sure an AssertionError was raised without checking the message text (I hope that's what you intended and not just removing the assert completely). I've also removed the blurb.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@rhettinger: please review the changes made to this pull request.

1 similar comment
@bedevere-bot
Copy link

Thanks for making the requested changes!

@rhettinger: please review the changes made to this pull request.

return ["Hello, world!"]
out, err = run_amock(bad_app)
self.assertTrue(out.endswith(
b"A server error occurred. Please contact the administrator."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove the double whitespace on occurred. Please

"AssertionError: Hop-by-hop header, 'Connection: close',"
" not allowed"
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the assertRaise is poorly written

@eamanu
Copy link
Contributor

eamanu commented Dec 25, 2018

I am running the test_wsgiref but the test_hop_by_hop_validation_error is skipped. But my python is not compiled with optimizations. :-O

@rhettinger
Copy link
Contributor

Removed the unneeded and incorrect test, leaving only the error message improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments