Skip to content

Commit 5b3b02b

Browse files
committed
tests: cover safe_getattr
1 parent f584444 commit 5b3b02b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

testing/test_compat.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ async def bar():
146146

147147

148148
class ErrorsHelper:
149+
@property
150+
def raise_baseexception(self):
151+
raise BaseException("base exception should be raised")
152+
149153
@property
150154
def raise_exception(self):
151155
raise Exception("exception should be catched")
@@ -167,6 +171,8 @@ def test_safe_getattr():
167171
helper = ErrorsHelper()
168172
assert safe_getattr(helper, "raise_exception", "default") == "default"
169173
assert safe_getattr(helper, "raise_fail", "default") == "default"
174+
with pytest.raises(BaseException):
175+
assert safe_getattr(helper, "raise_baseexception", "default")
170176

171177

172178
def test_safe_isclass():

0 commit comments

Comments
 (0)