def testStream_15(self): s = Stream(encoders=[str_encoder('utf-8'), gzip_encoder()]) s2 = Stream((str is not bytes), encoders=[gzip_decoder(), str_decoder('utf-8')]) retvalue = [] rc = self.rc def write_routine(): for m in s.write('abcde', rc): yield m for m in s.write('defgh', rc): yield m for m in s.write('ijklm', rc, True): yield m def read_routine(): for m in s2.read(rc): yield m retvalue.append(rc.data) rc.subroutine(write_routine()) rc.subroutine(read_routine()) rc.subroutine(s.copyTo(s2, rc)) self.server.serve() self.assertEqual(retvalue, ['abcdedefghijklm'])
def testStream_14(self): s = Stream(encoders=[str_encoder('utf-8'), deflate_encoder()]) s2 = Stream((str is not bytes), encoders=[deflate_decoder(), str_decoder('utf-8')]) retvalue = [] rc = self.rc async def write_routine(): await s.write('abcde', rc) await s.write('defgh', rc) await s.write('ijklm', rc, True) async def read_routine(): data = await s2.read(rc) retvalue.append(data) rc.subroutine(write_routine()) rc.subroutine(read_routine()) rc.subroutine(s.copyTo(s2, rc)) self.server.serve() self.assertEqual(retvalue, ['abcdedefghijklm'])
def testStream_9(self): s = Stream() s2 = Stream() retvalue = [] rc = self.rc async def write_routine(): await s.write(b'abcde', rc) await s.write(b'defgh', rc) await s.write(b'ijklm', rc, True) async def read_routine(): data = await s2.read(rc) retvalue.append(data) rc.subroutine(write_routine()) rc.subroutine(read_routine()) rc.subroutine(s.copyTo(s2, rc)) self.server.serve() self.assertEqual(retvalue, [b'abcdedefghijklm'])
def testStream_15(self): s = Stream(encoders=[str_encoder('utf-8'), gzip_encoder()]) s2 = Stream((str is not bytes), encoders=[gzip_decoder(), str_decoder('utf-8')]) retvalue = [] rc = self.rc def write_routine(): for m in s.write('abcde', rc): yield m for m in s.write('defgh', rc): yield m for m in s.write('ijklm', rc, True): yield m def read_routine(): for m in s2.read(rc): yield m retvalue.append(rc.data) rc.subroutine(write_routine()) rc.subroutine(read_routine()) rc.subroutine(s.copyTo(s2, rc)) self.server.serve() self.assertEqual(retvalue, ['abcdedefghijklm'])
def testStream_9(self): s = Stream() s2 = Stream() retvalue = [] rc = self.rc def write_routine(): for m in s.write(b'abcde', rc): yield m for m in s.write(b'defgh', rc): yield m for m in s.write(b'ijklm', rc, True): yield m def read_routine(): for m in s2.read(rc): yield m retvalue.append(rc.data) rc.subroutine(write_routine()) rc.subroutine(read_routine()) rc.subroutine(s.copyTo(s2, rc)) self.server.serve() self.assertEqual(retvalue, [b'abcdedefghijklm'])
def testStream_9(self): s = Stream() s2 = Stream() retvalue = [] rc = self.rc def write_routine(): for m in s.write(b'abcde', rc): yield m for m in s.write(b'defgh', rc): yield m for m in s.write(b'ijklm', rc, True): yield m def read_routine(): for m in s2.read(rc): yield m retvalue.append(rc.data) rc.subroutine(write_routine()) rc.subroutine(read_routine()) rc.subroutine(s.copyTo(s2, rc)) self.server.serve() self.assertEqual(retvalue, [b'abcdedefghijklm'])