Exemple #1
0
 def test_readlines_wait_error(self):
     reader = StreamReader()
     reader.feed(b'foo\n')
     def write_more():
         gruvi.sleep(0.01)
         reader.feed(b'bar\n')
         gruvi.sleep(0.01)
         reader.feed_error(RuntimeError)
     gruvi.spawn(write_more)
     self.assertEqual(reader.readlines(), [b'foo\n', b'bar\n'])
     self.assertRaises(RuntimeError, reader.readlines)
Exemple #2
0
 def test_readlines_wait_eof(self):
     reader = StreamReader()
     reader.feed(b'foo\n')
     def write_more():
         gruvi.sleep(0.01)
         reader.feed(b'bar\n')
         gruvi.sleep(0.01)
         reader.feed_eof()
     gruvi.spawn(write_more)
     self.assertEqual(reader.readlines(), [b'foo\n', b'bar\n'])
     self.assertEqual(reader.readlines(), [])
Exemple #3
0
    def test_readlines_wait_error(self):
        reader = StreamReader()
        reader.feed(b'foo\n')

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

        gruvi.spawn(write_more)
        self.assertEqual(reader.readlines(), [b'foo\n', b'bar\n'])
        self.assertRaises(RuntimeError, reader.readlines)
Exemple #4
0
    def test_readlines_wait_eof(self):
        reader = StreamReader()
        reader.feed(b'foo\n')

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

        gruvi.spawn(write_more)
        self.assertEqual(reader.readlines(), [b'foo\n', b'bar\n'])
        self.assertEqual(reader.readlines(), [])
Exemple #5
0
 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)
Exemple #6
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(), [])
Exemple #7
0
 def test_readlines_limit(self):
     reader = StreamReader()
     reader.feed(b'foo\nbar\n')
     self.assertEqual(reader.readlines(4), [b'foo\n', b'bar\n'])
Exemple #8
0
 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)
Exemple #9
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(), [])
Exemple #10
0
 def test_readlines_limit(self):
     reader = StreamReader()
     reader.feed(b'foo\nbar\n')
     self.assertEqual(reader.readlines(4), [b'foo\n', b'bar\n'])