-
Notifications
You must be signed in to change notification settings - Fork 1.7k
test: fix dead assert in retry streaming tests causing coverage issues #17723
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -263,7 +263,7 @@ def test___call___with_generator_send_retry(self, sleep): | |||||
| with pytest.raises(TypeError) as exc_info: | ||||||
| # calling first send with non-None input should raise a TypeError | ||||||
| result.send("can not send to fresh generator") | ||||||
| assert exc_info.match("can't send non-None value") | ||||||
| assert exc_info.match("can't send non-None value") | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Additionally, you can simplify this entire block by passing the with pytest.raises(TypeError, match="can't send non-None value"):
# calling first send with non-None input should raise a TypeError
result.send("can not send to fresh generator")
Suggested change
|
||||||
| # initiate iteration with None | ||||||
| result = retry_(self._generator_mock)(error_on=3) | ||||||
| assert result.send(None) == 0 | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
assertkeyword is redundant here becauseexc_info.match()already performs the assertion internally and raises a failure if the pattern does not match.Additionally, you can simplify this entire block by passing the
matchparameter directly topytest.raises, which is the idiomatic way to assert both the exception type and message in pytest: