def test_read_eof(self): reader = StreamReader() reader.feed(b'foo') reader.feed_eof() self.assertEqual(reader.read(), b'foo') self.assertEqual(reader.read(), b'') reader.feed_error(RuntimeError)
def test_iter_error(self): reader = StreamReader() reader.feed(b'foo\nbar\n') reader.feed_error(RuntimeError) it = iter(reader) self.assertEqual(six.next(it), b'foo\n') self.assertEqual(six.next(it), b'bar\n') self.assertRaises(RuntimeError, six.next, it)
def test_readlines_error(self): reader = StreamReader() reader.feed(b'foo\nbar\n') reader.feed_error(RuntimeError) self.assertEqual(reader.readlines(), [b'foo\n', b'bar\n']) self.assertRaises(RuntimeError, reader.readlines)
def test_readline_error(self): reader = StreamReader() reader.feed(b'foo') reader.feed_error(RuntimeError) self.assertEqual(reader.readline(), b'foo') self.assertRaises(RuntimeError, reader.readline)