Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Update test_raise.py from 3.13.11
  • Loading branch information
ShaharNaveh committed Dec 12, 2025
commit 74747e107d5f14c9fcdf053a66b8269c5221c05e
18 changes: 7 additions & 11 deletions Lib/test/test_raise.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,14 @@ def test_class_cause(self):

@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: 'classmethod' object is not callable
def test_class_cause_nonexception_result(self):
class ConstructsNone(BaseException):
@classmethod
# See https://github.com/python/cpython/issues/140530.
class ConstructMortal(BaseException):
def __new__(*args, **kwargs):
return None
try:
raise IndexError from ConstructsNone
except TypeError as e:
self.assertIn("should have returned an instance of BaseException", str(e))
except IndexError:
self.fail("Wrong kind of exception raised")
else:
self.fail("No exception raised")
return ["mortal value"]

msg = ".*should have returned an instance of BaseException.*"
with self.assertRaisesRegex(TypeError, msg):
raise IndexError from ConstructMortal

def test_instance_cause(self):
cause = KeyError()
Expand Down
Loading