mirror of
https://github.com/python/cpython.git
synced 2025-10-18 04:38:07 +00:00
bpo-37223: test_io: silence destructor errors (GH-13954)
Implement also MockNonBlockWriterIO.seek() method.
This commit is contained in:
parent
4f6f7c5a61
commit
b589cef9c4
1 changed files with 10 additions and 0 deletions
|
@ -277,6 +277,10 @@ class MockNonBlockWriterIO:
|
||||||
def seekable(self):
|
def seekable(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def seek(self, pos, whence=0):
|
||||||
|
# naive implementation, enough for tests
|
||||||
|
return 0
|
||||||
|
|
||||||
def writable(self):
|
def writable(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -1486,6 +1490,9 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
|
||||||
self.assertRaises(OSError, bufio.seek, 0)
|
self.assertRaises(OSError, bufio.seek, 0)
|
||||||
self.assertRaises(OSError, bufio.tell)
|
self.assertRaises(OSError, bufio.tell)
|
||||||
|
|
||||||
|
# Silence destructor error
|
||||||
|
bufio.close = lambda: None
|
||||||
|
|
||||||
def test_no_extraneous_read(self):
|
def test_no_extraneous_read(self):
|
||||||
# Issue #9550; when the raw IO object has satisfied the read request,
|
# Issue #9550; when the raw IO object has satisfied the read request,
|
||||||
# we should not issue any additional reads, otherwise it may block
|
# we should not issue any additional reads, otherwise it may block
|
||||||
|
@ -1834,6 +1841,9 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
|
||||||
self.assertRaises(OSError, bufio.tell)
|
self.assertRaises(OSError, bufio.tell)
|
||||||
self.assertRaises(OSError, bufio.write, b"abcdef")
|
self.assertRaises(OSError, bufio.write, b"abcdef")
|
||||||
|
|
||||||
|
# Silence destructor error
|
||||||
|
bufio.close = lambda: None
|
||||||
|
|
||||||
def test_max_buffer_size_removal(self):
|
def test_max_buffer_size_removal(self):
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
self.tp(self.MockRawIO(), 8, 12)
|
self.tp(self.MockRawIO(), 8, 12)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue