Skip to content

Commit 29703a5

Browse files
authored
Merge pull request #6466 from blueyed/cover-safe_getattr
tests: cover safe_getattr
2 parents f584444 + 6f7a95c commit 29703a5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

testing/test_compat.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,16 @@ 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")
152156

153157
@property
154-
def raise_fail(self):
158+
def raise_fail_outcome(self):
155159
pytest.fail("fail should be catched")
156160

157161

@@ -160,13 +164,15 @@ def test_helper_failures():
160164
with pytest.raises(Exception):
161165
helper.raise_exception
162166
with pytest.raises(OutcomeException):
163-
helper.raise_fail
167+
helper.raise_fail_outcome
164168

165169

166170
def test_safe_getattr():
167171
helper = ErrorsHelper()
168172
assert safe_getattr(helper, "raise_exception", "default") == "default"
169-
assert safe_getattr(helper, "raise_fail", "default") == "default"
173+
assert safe_getattr(helper, "raise_fail_outcome", "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)