Skip to content

Commit 901324f

Browse files
authored
Update test_raise.py from 3.13.11 (#6423)
1 parent 30dd5be commit 901324f

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

Lib/test/test_raise.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,14 @@ def test_class_cause(self):
187187

188188
@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: 'classmethod' object is not callable
189189
def test_class_cause_nonexception_result(self):
190-
class ConstructsNone(BaseException):
191-
@classmethod
190+
# See https://github.com/python/cpython/issues/140530.
191+
class ConstructMortal(BaseException):
192192
def __new__(*args, **kwargs):
193-
return None
194-
try:
195-
raise IndexError from ConstructsNone
196-
except TypeError as e:
197-
self.assertIn("should have returned an instance of BaseException", str(e))
198-
except IndexError:
199-
self.fail("Wrong kind of exception raised")
200-
else:
201-
self.fail("No exception raised")
193+
return ["mortal value"]
194+
195+
msg = ".*should have returned an instance of BaseException.*"
196+
with self.assertRaisesRegex(TypeError, msg):
197+
raise IndexError from ConstructMortal
202198

203199
def test_instance_cause(self):
204200
cause = KeyError()

0 commit comments

Comments
 (0)