def test_normal_read(self): with temppath() as tpath: with open(tpath, 'w') as writer: writer.write('abcd') with open(tpath) as reader: sreader = _SeekableReader(reader) eq_(sreader.read(3), 'abc') eq_(sreader.read(2), 'd') ok_(not sreader.read(1))
def test_buffered_read(self): with temppath() as tpath: with open(tpath, 'w') as writer: writer.write('abcdefghi') with open(tpath) as reader: sreader = _SeekableReader(reader, 3) eq_(sreader.read(1), 'a') eq_(sreader.read(3), 'bcd') sreader.seek(-3, os.SEEK_CUR) eq_(sreader.read(2), 'bc') eq_(sreader.read(6), 'defghi') ok_(not sreader.read(1))