MCPcopy Index your code
hub / github.com/python/cpython / test_reconfigure_defaults

Method test_reconfigure_defaults

Lib/test/test_io/test_textio.py:1259–1280  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1257 self.assertEqual(raw.getvalue(), b'abc\n\xef\xbb\xbfd\xc3\xa9f\n')
1258
1259 def test_reconfigure_defaults(self):
1260 txt = self.TextIOWrapper(self.BytesIO(), 'ascii', 'replace', '\n')
1261 txt.reconfigure(encoding=None)
1262 self.assertEqual(txt.encoding, 'ascii')
1263 self.assertEqual(txt.errors, 'replace')
1264 txt.write('LF\n')
1265
1266 txt.reconfigure(newline='\r\n')
1267 self.assertEqual(txt.encoding, 'ascii')
1268 self.assertEqual(txt.errors, 'replace')
1269
1270 txt.reconfigure(errors='ignore')
1271 self.assertEqual(txt.encoding, 'ascii')
1272 self.assertEqual(txt.errors, 'ignore')
1273 txt.write('CRLF\n')
1274
1275 txt.reconfigure(encoding='utf-8', newline=None)
1276 self.assertEqual(txt.errors, 'strict')
1277 txt.seek(0)
1278 self.assertEqual(txt.read(), 'LF\nCRLF\n')
1279
1280 self.assertEqual(txt.detach().getvalue(), b'LF\nCRLF\r\n')
1281
1282 def test_reconfigure_errors(self):
1283 txt = self.TextIOWrapper(self.BytesIO(), 'ascii', 'replace', '\r')

Callers

nothing calls this directly

Calls 7

reconfigureMethod · 0.95
writeMethod · 0.95
seekMethod · 0.95
readMethod · 0.95
detachMethod · 0.95
assertEqualMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected