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