(self)
| 942 | txt.flush = lambda: None # break reference loop |
| 943 | |
| 944 | def test_close_error_on_close(self): |
| 945 | buffer = self.BytesIO(self.testdata) |
| 946 | def bad_flush(): |
| 947 | raise OSError('flush') |
| 948 | def bad_close(): |
| 949 | raise OSError('close') |
| 950 | buffer.close = bad_close |
| 951 | txt = self.TextIOWrapper(buffer, encoding="ascii") |
| 952 | txt.flush = bad_flush |
| 953 | with self.assertRaises(OSError) as err: # exception not swallowed |
| 954 | txt.close() |
| 955 | self.assertEqual(err.exception.args, ('close',)) |
| 956 | self.assertIsInstance(err.exception.__context__, OSError) |
| 957 | self.assertEqual(err.exception.__context__.args, ('flush',)) |
| 958 | self.assertFalse(txt.closed) |
| 959 | |
| 960 | # Silence destructor error |
| 961 | buffer.close = lambda: None |
| 962 | txt.flush = lambda: None |
| 963 | |
| 964 | def test_nonnormalized_close_error_on_close(self): |
| 965 | # Issue #21677 |
nothing calls this directly
no test coverage detected