Author: Alex Gaynor <alex.gay...@gmail.com> Branch: py3k Changeset: r48954:5c7c60f852c7 Date: 2011-11-08 11:26 -0500 http://bitbucket.org/pypy/pypy/changeset/5c7c60f852c7/
Log: merged upstream diff --git a/pypy/module/_io/test/test_textio.py b/pypy/module/_io/test/test_textio.py --- a/pypy/module/_io/test/test_textio.py +++ b/pypy/module/_io/test/test_textio.py @@ -215,6 +215,26 @@ # that subprocess.Popen() can have the required unbuffered # semantics with universal_newlines=True. import _io + raw = self.get_MockRawIO()([b'abc', b'def', b'ghi\njkl\nopq\n']) + txt = _io.TextIOWrapper(raw, encoding='ascii', newline='\n') + # Reads + assert txt.read(4) == 'abcd' + assert txt.readline() == 'efghi\n' + assert list(txt) == ['jkl\n', 'opq\n'] + + def test_rawio_write_through(self): + # Issue #12591: with write_through=True, writes don't need a flush + import _io + raw = self.get_MockRawIO()([b'abc', b'def', b'ghi\njkl\nopq\n']) + txt = _io.TextIOWrapper(raw, encoding='ascii', newline='\n', + write_through=True) + txt.write('1') + txt.write('23\n4') + txt.write('5') + assert b''.join(raw._write_stack) == b'123\n45' + + def w_get_MockRawIO(self): + import _io class MockRawIO(_io._RawIOBase): def __init__(self, read_stack=()): self._read_stack = list(read_stack) @@ -275,24 +295,7 @@ except: self._extraneous_reads += 1 return b"" - - raw = MockRawIO([b'abc', b'def', b'ghi\njkl\nopq\n']) - txt = _io.TextIOWrapper(raw, encoding='ascii', newline='\n') - # Reads - assert txt.read(4) == 'abcd' - assert txt.readline() == 'efghi\n' - assert list(txt) == ['jkl\n', 'opq\n'] -# -# def test_rawio_write_through(self): -# # Issue #12591: with write_through=True, writes don't need a flush -# import _io - raw = MockRawIO([b'abc', b'def', b'ghi\njkl\nopq\n']) - txt = _io.TextIOWrapper(raw, encoding='ascii', newline='\n', - write_through=True) - txt.write('1') - txt.write('23\n4') - txt.write('5') - assert b''.join(raw._write_stack) == b'123\n45' + return MockRawIO class AppTestIncrementalNewlineDecoder: _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit