Esempio n. 1
0
 def test_readline(self):
     reader = StreamReader()
     reader.feed(b'foo\n')
     self.assertEqual(reader.readline(), b'foo\n')
     reader.feed(b'bar\nbaz\n')
     self.assertEqual(reader.readline(), b'bar\n')
     self.assertEqual(reader.readline(), b'baz\n')
Esempio n. 2
0
 def test_readline(self):
     reader = StreamReader()
     reader.feed(b'foo\n')
     self.assertEqual(reader.readline(), b'foo\n')
     reader.feed(b'bar\nbaz\n')
     self.assertEqual(reader.readline(), b'bar\n')
     self.assertEqual(reader.readline(), b'baz\n')
Esempio n. 3
0
 def test_readline_incr(self):
     reader = StreamReader()
     buf = b'foo\nbar\n'
     for i in range(len(buf)):
         reader.feed(buf[i:i+1])
     self.assertEqual(reader.readline(), b'foo\n')
     self.assertEqual(reader.readline(), b'bar\n')
Esempio n. 4
0
 def test_readline_incr(self):
     reader = StreamReader()
     buf = b'foo\nbar\n'
     for i in range(len(buf)):
         reader.feed(buf[i:i + 1])
     self.assertEqual(reader.readline(), b'foo\n')
     self.assertEqual(reader.readline(), b'bar\n')
Esempio n. 5
0
 def test_readline_wait_error(self):
     reader = StreamReader()
     reader.feed(b'foo')
     def write_more():
         gruvi.sleep(0.01)
         reader.feed(b'bar')
         gruvi.sleep(0.01)
         reader.feed_error(RuntimeError)
     gruvi.spawn(write_more)
     self.assertEqual(reader.readline(), b'foobar')
     self.assertRaises(RuntimeError, reader.readline)
Esempio n. 6
0
 def test_readline_wait_eof(self):
     reader = StreamReader()
     reader.feed(b'foo')
     def write_more():
         gruvi.sleep(0.01)
         reader.feed(b'bar')
         gruvi.sleep(0.01)
         reader.feed_eof()
     gruvi.spawn(write_more)
     self.assertEqual(reader.readline(), b'foobar')
     self.assertEqual(reader.readline(), b'')
Esempio n. 7
0
    def test_readline_wait_error(self):
        reader = StreamReader()
        reader.feed(b'foo')

        def write_more():
            gruvi.sleep(0.01)
            reader.feed(b'bar')
            gruvi.sleep(0.01)
            reader.feed_error(RuntimeError)

        gruvi.spawn(write_more)
        self.assertEqual(reader.readline(), b'foobar')
        self.assertRaises(RuntimeError, reader.readline)
Esempio n. 8
0
    def test_readline_wait_eof(self):
        reader = StreamReader()
        reader.feed(b'foo')

        def write_more():
            gruvi.sleep(0.01)
            reader.feed(b'bar')
            gruvi.sleep(0.01)
            reader.feed_eof()

        gruvi.spawn(write_more)
        self.assertEqual(reader.readline(), b'foobar')
        self.assertEqual(reader.readline(), b'')
Esempio n. 9
0
 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)
Esempio n. 10
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'')
Esempio n. 11
0
 def test_readline_limit(self):
     reader = StreamReader()
     reader.feed(b'foobar\n')
     self.assertEqual(reader.readline(3), b'foo')
     self.assertEqual(reader.readline(), b'bar\n')
Esempio n. 12
0
 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)
Esempio n. 13
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'')
Esempio n. 14
0
 def test_readline_limit(self):
     reader = StreamReader()
     reader.feed(b'foobar\n')
     self.assertEqual(reader.readline(3), b'foo')
     self.assertEqual(reader.readline(), b'bar\n')