Skip to content

Commit c6f2e73

Browse files
committed
Upgrade test_io from 3.13.11
1 parent 554ff9d commit c6f2e73

1 file changed

Lines changed: 48 additions & 43 deletions

File tree

Lib/test/test_io.py

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,10 +1818,6 @@ def test_garbage_collection(self):
18181818
support.gc_collect()
18191819
self.assertIsNone(wr(), wr)
18201820

1821-
@unittest.expectedFailure # TODO: RUSTPYTHON
1822-
def test_error_through_destructor(self):
1823-
return super().test_error_through_destructor()
1824-
18251821
def test_args_error(self):
18261822
# Issue #17275
18271823
with self.assertRaisesRegex(TypeError, "BufferedReader"):
@@ -1844,8 +1840,8 @@ def test_bad_readinto_type(self):
18441840
self.assertIsInstance(cm.exception.__cause__, TypeError)
18451841

18461842
@unittest.expectedFailure # TODO: RUSTPYTHON
1847-
def test_flush_error_on_close(self):
1848-
return super().test_flush_error_on_close()
1843+
def test_error_through_destructor(self):
1844+
return super().test_error_through_destructor()
18491845

18501846
@unittest.expectedFailure # TODO: RUSTPYTHON
18511847
def test_seek_character_device_file(self):
@@ -2166,10 +2162,6 @@ def test_slow_close_from_thread(self):
21662162
class CBufferedWriterTest(BufferedWriterTest, SizeofTest):
21672163
tp = io.BufferedWriter
21682164

2169-
@unittest.expectedFailure # TODO: RUSTPYTHON
2170-
def test_error_through_destructor(self):
2171-
return super().test_error_through_destructor()
2172-
21732165
def test_initialization(self):
21742166
rawio = self.MockRawIO()
21752167
bufio = self.tp(rawio)
@@ -2205,8 +2197,8 @@ def test_args_error(self):
22052197
self.tp(self.BytesIO(), 1024, 1024, 1024)
22062198

22072199
@unittest.expectedFailure # TODO: RUSTPYTHON
2208-
def test_flush_error_on_close(self):
2209-
return super().test_flush_error_on_close()
2200+
def test_error_through_destructor(self):
2201+
return super().test_error_through_destructor()
22102202

22112203
@unittest.skip('TODO: RUSTPYTHON; fallible allocation')
22122204
def test_constructor(self):
@@ -2692,10 +2684,6 @@ def test_interleaved_readline_write(self):
26922684
class CBufferedRandomTest(BufferedRandomTest, SizeofTest):
26932685
tp = io.BufferedRandom
26942686

2695-
@unittest.expectedFailure # TODO: RUSTPYTHON
2696-
def test_error_through_destructor(self):
2697-
return super().test_error_through_destructor()
2698-
26992687
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON; cyclic GC not supported, causes file locking')
27002688
@unittest.expectedFailure # TODO: RUSTPYTHON
27012689
def test_garbage_collection(self):
@@ -2708,17 +2696,13 @@ def test_args_error(self):
27082696
self.tp(self.BytesIO(), 1024, 1024, 1024)
27092697

27102698
@unittest.expectedFailure # TODO: RUSTPYTHON
2711-
def test_flush_error_on_close(self):
2712-
return super().test_flush_error_on_close()
2699+
def test_error_through_destructor(self):
2700+
return super().test_error_through_destructor()
27132701

27142702
@unittest.expectedFailure # TODO: RUSTPYTHON
27152703
def test_seek_character_device_file(self):
27162704
return super().test_seek_character_device_file()
27172705

2718-
@unittest.expectedFailure # TODO: RUSTPYTHON; f.read1(1) returns b'a'
2719-
def test_read1_after_write(self):
2720-
return super().test_read1_after_write()
2721-
27222706
@unittest.skip('TODO: RUSTPYTHON; fallible allocation')
27232707
def test_constructor(self):
27242708
return super().test_constructor()
@@ -3395,7 +3379,24 @@ def test_multibyte_seek_and_tell(self):
33953379
self.assertEqual(f.tell(), p1)
33963380
f.close()
33973381

3398-
@unittest.expectedFailure # TODO: RUSTPYTHON
3382+
def test_tell_after_readline_with_cr(self):
3383+
# Test for gh-141314: TextIOWrapper.tell() assertion failure
3384+
# when dealing with standalone carriage returns
3385+
data = b'line1\r'
3386+
with self.open(os_helper.TESTFN, "wb") as f:
3387+
f.write(data)
3388+
3389+
with self.open(os_helper.TESTFN, "r") as f:
3390+
# Read line that ends with \r
3391+
line = f.readline()
3392+
self.assertEqual(line, "line1\n")
3393+
# This should not cause an assertion failure
3394+
pos = f.tell()
3395+
# Verify we can seek back to this position
3396+
f.seek(pos)
3397+
remaining = f.read()
3398+
self.assertEqual(remaining, "")
3399+
33993400
def test_seek_with_encoder_state(self):
34003401
f = self.open(os_helper.TESTFN, "w", encoding="euc_jis_2004")
34013402
f.write("\u00e6\u0300")
@@ -4130,10 +4131,6 @@ class CTextIOWrapperTest(TextIOWrapperTest):
41304131
io = io
41314132
shutdown_error = "LookupError: unknown encoding: ascii"
41324133

4133-
@unittest.expectedFailure # TODO: RUSTPYTHON
4134-
def test_error_through_destructor(self):
4135-
return super().test_error_through_destructor()
4136-
41374134
@unittest.expectedFailure # TODO: RUSTPYTHON
41384135
def test_initialization(self):
41394136
r = self.BytesIO(b"\xc3\xa9\n\n")
@@ -4291,6 +4288,10 @@ def test_reconfigure_write_fromascii(self):
42914288
def test_reconfigure_write_through(self):
42924289
return super().test_reconfigure_write_through()
42934290

4291+
@unittest.expectedFailure # TODO: RUSTPYTHON
4292+
def test_error_through_destructor(self):
4293+
return super().test_error_through_destructor()
4294+
42944295
@unittest.expectedFailure # TODO: RUSTPYTHON
42954296
def test_repr(self):
42964297
return super().test_repr()
@@ -4306,6 +4307,11 @@ def test_recursive_repr(self):
43064307
def test_pickling_subclass(self):
43074308
return super().test_pickling_subclass()
43084309

4310+
# TODO: RUSTPYTHON; euc_jis_2004 encoding not supported
4311+
@unittest.expectedFailure
4312+
def test_seek_with_encoder_state(self):
4313+
return super().test_seek_with_encoder_state()
4314+
43094315

43104316
class PyTextIOWrapperTest(TextIOWrapperTest):
43114317
io = pyio
@@ -4319,6 +4325,11 @@ def test_constructor(self):
43194325
def test_newlines(self):
43204326
return super().test_newlines()
43214327

4328+
# TODO: RUSTPYTHON; euc_jis_2004 encoding not supported
4329+
@unittest.expectedFailure
4330+
def test_seek_with_encoder_state(self):
4331+
return super().test_seek_with_encoder_state()
4332+
43224333

43234334
class IncrementalNewlineDecoderTest(unittest.TestCase):
43244335

@@ -4836,22 +4847,6 @@ class CMiscIOTest(MiscIOTest):
48364847
name_of_module = "io", "_io"
48374848
extra_exported = "BlockingIOError",
48384849

4839-
@unittest.expectedFailure # TODO: RUSTPYTHON; BufferedWriter seeks on non-seekable pipe
4840-
def test_nonblock_pipe_write_bigbuf(self):
4841-
return super().test_nonblock_pipe_write_bigbuf()
4842-
4843-
@unittest.expectedFailure # TODO: RUSTPYTHON; BufferedWriter seeks on non-seekable pipe
4844-
def test_nonblock_pipe_write_smallbuf(self):
4845-
return super().test_nonblock_pipe_write_smallbuf()
4846-
4847-
@unittest.expectedFailure # TODO: RUSTPYTHON
4848-
def test_warn_on_dealloc(self):
4849-
return super().test_warn_on_dealloc()
4850-
4851-
@unittest.expectedFailure # TODO: RUSTPYTHON
4852-
def test_warn_on_dealloc_fd(self):
4853-
return super().test_warn_on_dealloc_fd()
4854-
48554850
def test_readinto_buffer_overflow(self):
48564851
# Issue #18025
48574852
class BadReader(self.io.BufferedIOBase):
@@ -4916,6 +4911,16 @@ def test_daemon_threads_shutdown_stderr_deadlock(self):
49164911
def test_check_encoding_errors(self):
49174912
return super().test_check_encoding_errors()
49184913

4914+
# TODO: RUSTPYTHON; ResourceWarning not triggered by _io.FileIO
4915+
@unittest.expectedFailure
4916+
def test_warn_on_dealloc(self):
4917+
return super().test_warn_on_dealloc()
4918+
4919+
# TODO: RUSTPYTHON; ResourceWarning not triggered by _io.FileIO
4920+
@unittest.expectedFailure
4921+
def test_warn_on_dealloc_fd(self):
4922+
return super().test_warn_on_dealloc_fd()
4923+
49194924

49204925
class PyMiscIOTest(MiscIOTest):
49214926
io = pyio

0 commit comments

Comments
 (0)