Home | History | Annotate | Download | only in test

Lines Matching refs:txt

2765             txt = self.TextIOWrapper(buf, encoding="ascii", newline=newline)
2766 self.assertEqual(txt.readlines(), expected)
2767 txt.seek(0)
2768 self.assertEqual(txt.read(), "".join(expected))
2780 txt = self.TextIOWrapper(buf, encoding="ascii", newline=newline)
2781 txt.write("AAA\nB")
2782 txt.write("BB\nCCC\n")
2783 txt.write("X\rY\r\nZ")
2784 txt.flush()
3012 txt = self.TextIOWrapper(UnReadable())
3013 self.assertRaises(OSError, txt.read)
3016 txt = self.TextIOWrapper(self.BytesIO(b"AA\r\nBB"))
3019 c = txt.read(1)
3026 txt = self.TextIOWrapper(self.BytesIO(b"AA\nBB\nCC"))
3027 self.assertEqual(txt.readlines(), ["AA\n", "BB\n", "CC"])
3028 txt.seek(0)
3029 self.assertEqual(txt.readlines(None), ["AA\n", "BB\n", "CC"])
3030 txt.seek(0)
3031 self.assertEqual(txt.readlines(5), ["AA\n", "BB\n"])
3036 txt = self.TextIOWrapper(self.BytesIO(b"A" * 127 + b"\r\nB"))
3039 c = txt.read(128)
3048 txt = self.TextIOWrapper(buf)
3049 txt.writelines(l)
3050 txt.flush()
3056 txt = self.TextIOWrapper(buf)
3057 txt.writelines(l)
3058 txt.flush()
3062 txt = self.TextIOWrapper(self.BytesIO())
3063 self.assertRaises(TypeError, txt.writelines, [1, 2, 3])
3064 self.assertRaises(TypeError, txt.writelines, None)
3065 self.assertRaises(TypeError, txt.writelines, b'abc')
3068 txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
3073 c = txt.read(1)
3080 txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
3081 txt._CHUNK_SIZE = 4
3085 c = txt.read(4)
3092 txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
3093 txt._CHUNK_SIZE = 4
3095 reads = txt.read(4)
3096 reads += txt.read(4)
3097 reads += txt.readline()
3098 reads += txt.readline()
3099 reads += txt.readline()
3103 txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
3104 txt._CHUNK_SIZE = 4
3106 reads = txt.read(4)
3107 reads += txt.read()
3111 txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
3112 txt._CHUNK_SIZE = 4
3114 reads = txt.read(4)
3115 pos = txt.tell()
3116 txt.seek(0)
3117 txt.seek(pos)
3118 self.assertEqual(txt.read(4), "BBB\n")
3122 txt = self.TextIOWrapper(buffer, encoding="ascii")
3124 self.assertEqual(buffer.seekable(), txt.seekable())
3196 txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
3199 closed[:] = [txt.closed, txt.buffer.closed]
3201 txt.flush = bad_flush
3202 self.assertRaises(OSError, txt.close) # exception not swallowed
3203 self.assertTrue(txt.closed)
3204 self.assertTrue(txt.buffer.closed)
3208 txt.flush = lambda: None # break reference loop
3217 txt = self.TextIOWrapper(buffer, encoding="ascii")
3218 txt.flush = bad_flush
3220 txt.close()
3224 self.assertFalse(txt.closed)
3234 txt = self.TextIOWrapper(buffer, encoding="ascii")
3235 txt.flush = bad_flush
3237 txt.close()
3241 self.assertFalse(txt.closed)
3244 txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
3245 txt.close()
3246 txt.close()
3247 txt.close()
3248 self.assertRaises(ValueError, txt.flush)
3251 txt = self.TextIOWrapper(self.MockUnseekableIO(self.testdata))
3252 self.assertRaises(self.UnsupportedOperation, txt.tell)
3253 self.assertRaises(self.UnsupportedOperation, txt.seek, 0)
3256 txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
3259 txt.buffer = buf
3266 txt = self.TextIOWrapper(raw, encoding='ascii', newline='\n')
3268 self.assertEqual(txt.read(4), 'abcd')
3269 self.assertEqual(txt.readline(), 'efghi\n')
3270 self.assertEqual(list(txt), ['jkl\n', 'opq\n'])
3275 txt = self.TextIOWrapper(raw, encoding='ascii', newline='\n',
3277 txt.write('1')
3278 txt.write('23\n4')
3279 txt.write('5')
3464 txt = self.TextIOWrapper(raw, encoding='latin1', newline='\n')
3465 self.assertEqual(txt.readline(), 'abc\xe9\n')
3467 txt.reconfigure(encoding='utf-8')
3469 txt.reconfigure(newline=None)
3476 txt = self.TextIOWrapper(raw, encoding='ascii', newline='\n')
3477 txt.write('foo\n')
3478 txt.reconfigure(encoding='utf-8-sig')
3479 txt.write('\xe9\n')
3480 txt.flush()
3486 txt = self.TextIOWrapper(raw, encoding='latin1', newline='\n')
3487 txt.write('abc\xe9\n')
3488 txt.reconfigure(encoding='utf-8')
3490 txt.write('d\xe9f\n')
3491 txt.flush()
3497 txt = self.TextIOWrapper(raw, encoding='ascii', newline='\n')
3498 txt.write('abc\n')
3499 txt.reconfigure(encoding='utf-8-sig')
3500 txt.write('d\xe9f\n')
3501 txt.flush()
3508 txt = self.TextIOWrapper(raw, encoding='ascii', newline='\n')
3509 txt.write('abc\n')
3510 txt.reconfigure(encoding='utf-8-sig')
3511 txt.write('d\xe9f\n')
3512 txt.flush()
3518 txt = self.TextIOWrapper(self.BytesIO(), 'ascii', 'replace', '\n')
3519 txt.reconfigure(encoding=None)
3520 self.assertEqual(txt.encoding, 'ascii')
3521 self.assertEqual(txt.errors, 'replace')
3522 txt.write('LF\n')
3524 txt.reconfigure(newline='\r\n')
3525 self.assertEqual(txt.encoding, 'ascii')
3526 self.assertEqual(txt
3528 txt.reconfigure(errors='ignore')
3529 self.assertEqual(txt.encoding, 'ascii')
3530 self.assertEqual(txt.errors, 'ignore')
3531 txt.write('CRLF\n')
3533 txt.reconfigure(encoding='utf-8', newline=None)
3534 self.assertEqual(txt.errors, 'strict')
3535 txt.seek(0)
3536 self.assertEqual(txt.read(), 'LF\nCRLF\n')
3538 self.assertEqual(txt.detach().getvalue(), b'LF\nCRLF\r\n')
3542 txt = self.TextIOWrapper(raw, 'ascii', newline='\n')
3543 txt.reconfigure(newline=None)
3544 self.assertEqual(txt.readline(), 'CR\n')
3546 txt = self.TextIOWrapper(raw, 'ascii', newline='\n')
3547 txt.reconfigure(newline='')
3548 self.assertEqual(txt.readline(), 'CR\r')
3550 txt = self.TextIOWrapper(raw, 'ascii', newline='\r')
3551 txt.reconfigure(newline='\n')
3552 self.assertEqual(txt.readline(), 'CR\rLF\n')
3554 txt = self.TextIOWrapper(raw, 'ascii', newline='\n')
3555 txt.reconfigure(newline='\r')
3556 self.assertEqual(txt.readline(), 'LF\nCR\r')
3558 txt = self.TextIOWrapper(raw, 'ascii', newline='\r')
3559 txt.reconfigure(newline='\r\n')
3560 self.assertEqual(txt.readline(), 'CR\rCRLF\r\n')
3562 txt = self.TextIOWrapper(self.BytesIO(), 'ascii', newline='\r')
3563 txt.reconfigure(newline=None)
3564 txt.write('linesep\n')
3565 txt.reconfigure(newline='')
3566 txt.write('LF\n')
3567 txt.reconfigure(newline='\n')
3568 txt.write('LF\n')
3569 txt.reconfigure(newline='\r')
3570 txt.write('CR\n')
3571 txt.reconfigure(newline='\r\n')
3572 txt.write('CRLF\n')
3574 self.assertEqual(txt.detach().getvalue().decode('ascii'), expected)