(self)
| 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') |
| 1284 | with self.assertRaises(TypeError): # there was a crash |
| 1285 | txt.reconfigure(encoding=42) |
| 1286 | if self.is_C: |
| 1287 | with self.assertRaises(UnicodeEncodeError): |
| 1288 | txt.reconfigure(encoding='\udcfe') |
| 1289 | with self.assertRaises(LookupError): |
| 1290 | txt.reconfigure(encoding='locale\0') |
| 1291 | # TODO: txt.reconfigure(encoding='utf-8\0') |
| 1292 | # TODO: txt.reconfigure(encoding='nonexisting') |
| 1293 | with self.assertRaises(TypeError): |
| 1294 | txt.reconfigure(errors=42) |
| 1295 | if self.is_C: |
| 1296 | with self.assertRaises(UnicodeEncodeError): |
| 1297 | txt.reconfigure(errors='\udcfe') |
| 1298 | # TODO: txt.reconfigure(errors='ignore\0') |
| 1299 | # TODO: txt.reconfigure(errors='nonexisting') |
| 1300 | with self.assertRaises(TypeError): |
| 1301 | txt.reconfigure(newline=42) |
| 1302 | with self.assertRaises(ValueError): |
| 1303 | txt.reconfigure(newline='\udcfe') |
| 1304 | with self.assertRaises(ValueError): |
| 1305 | txt.reconfigure(newline='xyz') |
| 1306 | if not self.is_C: |
| 1307 | # TODO: Should fail in C too. |
| 1308 | with self.assertRaises(ValueError): |
| 1309 | txt.reconfigure(newline='\n\0') |
| 1310 | if self.is_C: |
| 1311 | # TODO: Use __bool__(), not __index__(). |
| 1312 | with self.assertRaises(ZeroDivisionError): |
| 1313 | txt.reconfigure(line_buffering=BadIndex()) |
| 1314 | with self.assertRaises(OverflowError): |
| 1315 | txt.reconfigure(line_buffering=2**1000) |
| 1316 | with self.assertRaises(ZeroDivisionError): |
| 1317 | txt.reconfigure(write_through=BadIndex()) |
| 1318 | with self.assertRaises(OverflowError): |
| 1319 | txt.reconfigure(write_through=2**1000) |
| 1320 | with self.assertRaises(ZeroDivisionError): # there was a crash |
| 1321 | txt.reconfigure(line_buffering=BadIndex(), |
| 1322 | write_through=BadIndex()) |
| 1323 | self.assertEqual(txt.encoding, 'ascii') |
| 1324 | self.assertEqual(txt.errors, 'replace') |
| 1325 | self.assertIs(txt.line_buffering, False) |
| 1326 | self.assertIs(txt.write_through, False) |
| 1327 | |
| 1328 | txt.reconfigure(encoding='latin1', errors='ignore', newline='\r\n', |
| 1329 | line_buffering=True, write_through=True) |
| 1330 | self.assertEqual(txt.encoding, 'latin1') |
| 1331 | self.assertEqual(txt.errors, 'ignore') |
| 1332 | self.assertIs(txt.line_buffering, True) |
| 1333 | self.assertIs(txt.write_through, True) |
| 1334 | |
| 1335 | def test_reconfigure_newline(self): |
| 1336 | raw = self.BytesIO(b'CR\rEOF') |
nothing calls this directly
no test coverage detected