Skip to content
Merged
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
12 changes: 9 additions & 3 deletions testing/test_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,16 @@ async def bar():


class ErrorsHelper:
@property
def raise_baseexception(self):
raise BaseException("base exception should be raised")

@property
def raise_exception(self):
raise Exception("exception should be catched")

@property
def raise_fail(self):
def raise_fail_outcome(self):
pytest.fail("fail should be catched")


Expand All @@ -160,13 +164,15 @@ def test_helper_failures():
with pytest.raises(Exception):
helper.raise_exception
with pytest.raises(OutcomeException):
helper.raise_fail
helper.raise_fail_outcome


def test_safe_getattr():
helper = ErrorsHelper()
assert safe_getattr(helper, "raise_exception", "default") == "default"
assert safe_getattr(helper, "raise_fail", "default") == "default"
assert safe_getattr(helper, "raise_fail_outcome", "default") == "default"
with pytest.raises(BaseException):
assert safe_getattr(helper, "raise_baseexception", "default")
Copy link
Member

Choose a reason for hiding this comment

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

good find, i recall that we have outcome exception handling - if that's the case can you cover that as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean.
I've noticed that it's not covered with 85a813b#diff-4ec37b1ad5b7d41fdac56c907d08dde1R335-R340 (reverted there, but still).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

indeed, i missed that bit, thanks for calling out

i think i would have noted it better if it was named raise_fail_outcome, what do you think about the naming

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed.

Copy link
Member

Choose a reason for hiding this comment

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

@blueyed thanks, lovely



def test_safe_isclass():
Expand Down