예제 #1
0
 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)
예제 #2
0
 def test_read_incr(self):
     reader = StreamReader()
     buf = b'foobar'
     for i in range(len(buf)):
         reader.feed(buf[i:i + 1])
     reader.feed_eof()
     self.assertEqual(reader.read(), b'foobar')
예제 #3
0
 def test_read_incr(self):
     reader = StreamReader()
     buf = b'foobar'
     for i in range(len(buf)):
         reader.feed(buf[i:i+1])
     reader.feed_eof()
     self.assertEqual(reader.read(), b'foobar')
예제 #4
0
 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)
예제 #5
0
 def test_partial_decode_at_eof(self):
     reader = StreamReader()
     wrapped = TextIOWrapper(reader, 'utf-8')
     # \u20ac is the euro sign in case you wondered..
     buf = u'20 \u20ac'.encode('utf-8')
     reader.feed(buf[:-1])
     reader.feed_eof()
     self.assertRaises(UnicodeDecodeError, wrapped.read, 4)
예제 #6
0
 def test_iter_eof(self):
     reader = StreamReader()
     reader.feed(b'foo\nbar\n')
     reader.feed_eof()
     it = iter(reader)
     self.assertEqual(six.next(it), b'foo\n')
     self.assertEqual(six.next(it), b'bar\n')
     self.assertRaises(StopIteration, six.next, it)
예제 #7
0
 def test_partial_decode_at_eof(self):
     reader = StreamReader()
     wrapped = TextIOWrapper(reader, 'utf-8')
     # \u20ac is the euro sign in case you wondered..
     buf = u'20 \u20ac'.encode('utf-8')
     reader.feed(buf[:-1])
     reader.feed_eof()
     self.assertRaises(UnicodeDecodeError, wrapped.read, 4)
예제 #8
0
 def test_iter_eof(self):
     reader = StreamReader()
     reader.feed(b'foo\nbar\n')
     reader.feed_eof()
     it = iter(reader)
     self.assertEqual(six.next(it), b'foo\n')
     self.assertEqual(six.next(it), b'bar\n')
     self.assertRaises(StopIteration, six.next, it)
예제 #9
0
 def test_read_eof(self):
     reader = StreamReader()
     wrapped = TextIOWrapper(reader, 'utf-8')
     reader.feed(b'foo')
     reader.feed_eof()
     self.assertEqual(wrapped.read(), 'foo')
예제 #10
0
 def test_readlines_eof(self):
     reader = StreamReader()
     reader.feed(b'foo\nbar\n')
     reader.feed_eof()
     self.assertEqual(reader.readlines(), [b'foo\n', b'bar\n'])
     self.assertEqual(reader.readlines(), [])
예제 #11
0
 def test_readline_eof(self):
     reader = StreamReader()
     reader.feed(b'foo')
     reader.feed_eof()
     self.assertEqual(reader.readline(), b'foo')
     self.assertEqual(reader.readline(), b'')
예제 #12
0
 def test_read_eof(self):
     reader = StreamReader()
     wrapped = TextIOWrapper(reader, 'utf-8')
     reader.feed(b'foo')
     reader.feed_eof()
     self.assertEqual(wrapped.read(), 'foo')
예제 #13
0
 def test_readlines_eof(self):
     reader = StreamReader()
     reader.feed(b'foo\nbar\n')
     reader.feed_eof()
     self.assertEqual(reader.readlines(), [b'foo\n', b'bar\n'])
     self.assertEqual(reader.readlines(), [])
예제 #14
0
 def test_readline_eof(self):
     reader = StreamReader()
     reader.feed(b'foo')
     reader.feed_eof()
     self.assertEqual(reader.readline(), b'foo')
     self.assertEqual(reader.readline(), b'')