Skip to content

Commit 5177fff

Browse files
test
1 parent 831013f commit 5177fff

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

tests/test_utils.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -644,15 +644,14 @@ def test_is_sentry_url_no_client():
644644
],
645645
)
646646
def test_get_error_message(error, expected_result):
647-
with pytest.raises(BaseException) as exc_value:
648-
exc_value.message = error
649-
raise Exception
650-
assert get_error_message(exc_value) == expected_result(exc_value)
651-
652-
with pytest.raises(BaseException) as exc_value:
653-
exc_value.detail = error
654-
raise Exception
655-
assert get_error_message(exc_value) == expected_result(exc_value)
647+
class CustomException(Exception):
648+
def __str__(self):
649+
return expected_result(self)
650+
651+
with pytest.raises(CustomException) as exc:
652+
raise CustomException
653+
654+
assert get_error_message(exc.value) == expected_result(exc.value)
656655

657656

658657
def test_safe_str_fails():

0 commit comments

Comments
 (0)