Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ async def test___call___generator_send_retry(self, sleep):
generator = await retry_(self._generator_mock)(error_on=3)
with pytest.raises(TypeError) as exc_info:
await generator.asend("cannot send to fresh generator")
assert exc_info.match("can't send non-None value")
assert exc_info.match("can't send non-None value")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The assert keyword is redundant here because exc_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 match parameter directly to pytest.raises, which is the idiomatic way to assert both the exception type and message in pytest:

        with pytest.raises(TypeError, match="can't send non-None value"):
            await generator.asend("cannot send to fresh generator")
Suggested change
assert exc_info.match("can't send non-None value")
exc_info.match("can't send non-None value")

await generator.aclose()

# error thrown on 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The assert keyword is redundant here because exc_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 match parameter directly to pytest.raises, which is the idiomatic way to assert both the exception type and message in pytest:

        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
assert exc_info.match("can't send non-None value")
exc_info.match("can't send non-None value")

# initiate iteration with None
result = retry_(self._generator_mock)(error_on=3)
assert result.send(None) == 0
Expand Down
Loading