MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_reconfigure_newline

Method test_reconfigure_newline

Lib/test/test_io.py:3995–4029  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3993 self.assertIs(txt.write_through, True)
3994
3995 def test_reconfigure_newline(self):
3996 raw = self.BytesIO(b'CR\rEOF')
3997 txt = self.TextIOWrapper(raw, 'ascii', newline='\n')
3998 txt.reconfigure(newline=None)
3999 self.assertEqual(txt.readline(), 'CR\n')
4000 raw = self.BytesIO(b'CR\rEOF')
4001 txt = self.TextIOWrapper(raw, 'ascii', newline='\n')
4002 txt.reconfigure(newline='')
4003 self.assertEqual(txt.readline(), 'CR\r')
4004 raw = self.BytesIO(b'CR\rLF\nEOF')
4005 txt = self.TextIOWrapper(raw, 'ascii', newline='\r')
4006 txt.reconfigure(newline='\n')
4007 self.assertEqual(txt.readline(), 'CR\rLF\n')
4008 raw = self.BytesIO(b'LF\nCR\rEOF')
4009 txt = self.TextIOWrapper(raw, 'ascii', newline='\n')
4010 txt.reconfigure(newline='\r')
4011 self.assertEqual(txt.readline(), 'LF\nCR\r')
4012 raw = self.BytesIO(b'CR\rCRLF\r\nEOF')
4013 txt = self.TextIOWrapper(raw, 'ascii', newline='\r')
4014 txt.reconfigure(newline='\r\n')
4015 self.assertEqual(txt.readline(), 'CR\rCRLF\r\n')
4016
4017 txt = self.TextIOWrapper(self.BytesIO(), 'ascii', newline='\r')
4018 txt.reconfigure(newline=None)
4019 txt.write('linesep\n')
4020 txt.reconfigure(newline='')
4021 txt.write('LF\n')
4022 txt.reconfigure(newline='\n')
4023 txt.write('LF\n')
4024 txt.reconfigure(newline='\r')
4025 txt.write('CR\n')
4026 txt.reconfigure(newline='\r\n')
4027 txt.write('CRLF\n')
4028 expected = 'linesep' + os.linesep + 'LF\nLF\nCR\rCRLF\r\n'
4029 self.assertEqual(txt.detach().getvalue().decode('ascii'), expected)
4030
4031 def test_issue25862(self):
4032 # Assertion failures occurred in tell() after read() and write().

Callers

nothing calls this directly

Calls 7

reconfigureMethod · 0.95
readlineMethod · 0.95
writeMethod · 0.95
detachMethod · 0.95
assertEqualMethod · 0.45
decodeMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected