# Issue #25455
raw = self.MockRawIO()
b = self.tp(raw)
- with support.swap_attr(raw, 'name', b):
- try:
+ with support.swap_attr(raw, 'name', b), support.infinite_recursion(25):
+ with self.assertRaises(RuntimeError):
repr(b) # Should not crash
- except RuntimeError:
- pass
def test_flush_error_on_close(self):
# Test that buffered file is closed despite failed flush
# Issue #25455
raw = self.BytesIO()
t = self.TextIOWrapper(raw, encoding="utf-8")
- with support.swap_attr(raw, 'name', t):
- try:
+ with support.swap_attr(raw, 'name', t), support.infinite_recursion(25):
+ with self.assertRaises(RuntimeError):
repr(t) # Should not crash
- except RuntimeError:
- pass
def test_line_buffering(self):
r = self.BytesIO()