Skip to content

Commit b589cef

Browse files
authored
bpo-37223: test_io: silence destructor errors (GH-13954)
Implement also MockNonBlockWriterIO.seek() method.
1 parent 4f6f7c5 commit b589cef

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Lib/test/test_io.py

+10
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ def readable(self):
277277
def seekable(self):
278278
return True
279279

280+
def seek(self, pos, whence=0):
281+
# naive implementation, enough for tests
282+
return 0
283+
280284
def writable(self):
281285
return True
282286

@@ -1486,6 +1490,9 @@ def test_misbehaved_io(self):
14861490
self.assertRaises(OSError, bufio.seek, 0)
14871491
self.assertRaises(OSError, bufio.tell)
14881492

1493+
# Silence destructor error
1494+
bufio.close = lambda: None
1495+
14891496
def test_no_extraneous_read(self):
14901497
# Issue #9550; when the raw IO object has satisfied the read request,
14911498
# we should not issue any additional reads, otherwise it may block
@@ -1834,6 +1841,9 @@ def test_misbehaved_io(self):
18341841
self.assertRaises(OSError, bufio.tell)
18351842
self.assertRaises(OSError, bufio.write, b"abcdef")
18361843

1844+
# Silence destructor error
1845+
bufio.close = lambda: None
1846+
18371847
def test_max_buffer_size_removal(self):
18381848
with self.assertRaises(TypeError):
18391849
self.tp(self.MockRawIO(), 8, 12)

0 commit comments

Comments
 (0)