diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-04-12 21:58:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-12 21:58:24 +0200 |
commit | 472f794a33221ea835a2fbf6c9f12aa2bd66d1b0 (patch) | |
tree | 9f7df0ad7a7cf18230b5b91bd600085186b088ea /Lib/test/test_io.py | |
parent | e8f9acf03484c6c3f163f04a76321419369c28aa (diff) | |
download | cpython-git-472f794a33221ea835a2fbf6c9f12aa2bd66d1b0.tar.gz |
bpo-18748: test_io: silence destructor errors (GH-12805)
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r-- | Lib/test/test_io.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 811a446f92..5406a2891b 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -991,6 +991,9 @@ class IOTest(unittest.TestCase): # This would cause an assertion failure. self.assertRaises(OSError, f.close) + # Silence destructor error + R.flush = lambda self: None + class CIOTest(IOTest): @@ -1167,6 +1170,10 @@ class CommonBufferedTests: self.assertEqual(err.exception.__context__.args, ('flush',)) self.assertFalse(b.closed) + # Silence destructor error + raw.close = lambda: None + b.flush = lambda: None + def test_nonnormalized_close_error_on_close(self): # Issue #21677 raw = self.MockRawIO() @@ -1184,6 +1191,10 @@ class CommonBufferedTests: self.assertIn('non_existing_flush', str(err.exception.__context__)) self.assertFalse(b.closed) + # Silence destructor error + b.flush = lambda: None + raw.close = lambda: None + def test_multi_close(self): raw = self.MockRawIO() b = self.tp(raw) @@ -2039,6 +2050,9 @@ class BufferedRWPairTest(unittest.TestCase): self.assertFalse(reader.closed) self.assertTrue(writer.closed) + # Silence destructor error + reader.close = lambda: None + def test_writer_close_error_on_close(self): def writer_close(): writer_non_existing @@ -2053,6 +2067,9 @@ class BufferedRWPairTest(unittest.TestCase): self.assertTrue(reader.closed) self.assertFalse(writer.closed) + # Silence destructor error + writer.close = lambda: None + def test_reader_writer_close_error_on_close(self): def reader_close(): reader_non_existing @@ -2072,6 +2089,10 @@ class BufferedRWPairTest(unittest.TestCase): self.assertFalse(reader.closed) self.assertFalse(writer.closed) + # Silence destructor error + reader.close = lambda: None + writer.close = lambda: None + def test_isatty(self): class SelectableIsAtty(MockRawIO): def __init__(self, isatty): @@ -3270,6 +3291,10 @@ class TextIOWrapperTest(unittest.TestCase): self.assertEqual(err.exception.__context__.args, ('flush',)) self.assertFalse(txt.closed) + # Silence destructor error + buffer.close = lambda: None + txt.flush = lambda: None + def test_nonnormalized_close_error_on_close(self): # Issue #21677 buffer = self.BytesIO(self.testdata) @@ -3287,6 +3312,10 @@ class TextIOWrapperTest(unittest.TestCase): self.assertIn('non_existing_flush', str(err.exception.__context__)) self.assertFalse(txt.closed) + # Silence destructor error + buffer.close = lambda: None + txt.flush = lambda: None + def test_multi_close(self): txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii") txt.close() |