Esempio n. 1
0
 def test_read1_wait(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.read1(100), b'foo')
     self.assertEqual(reader.read1(100), b'bar')
     self.assertEqual(reader.read1(100), b'')
Esempio n. 2
0
    def test_read1_wait(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.read1(100), b'foo')
        self.assertEqual(reader.read1(100), b'bar')
        self.assertEqual(reader.read1(100), b'')
Esempio n. 3
0
 def test_read1(self):
     reader = StreamReader()
     reader.feed(b'foobar')
     self.assertEqual(reader.read1(3), b'foo')
     self.assertEqual(reader.read1(100), b'bar')
Esempio n. 4
0
 def test_read1(self):
     reader = StreamReader()
     reader.feed(b'foobar')
     self.assertEqual(reader.read1(3), b'foo')
     self.assertEqual(reader.read1(100), b'bar')