def test_echo_tcp(self): server = StreamServer(echo_handler) server.listen(('127.0.0.1', 0)) client = StreamClient() client.connect(server.addresses[0]) client.write(b'foo\n') client.write_eof() self.assertEqual(client.readline(), b'foo\n') server.close() client.close()
def test_echo_pipe(self): server = StreamServer(echo_handler) server.listen(self.pipename()) client = StreamClient() client.connect(server.addresses[0]) client.write(b'foo\n') client.write_eof() self.assertEqual(client.readline(), b'foo\n') self.assertEqual(client.readline(), b'') server.close() client.close()
def test_illegal_request(self): server = HttpServer(hello_app) server.listen(('localhost', 0)) addr = server.addresses[0] client = StreamClient() client.connect(addr) client.write(b'foo\r\n') client.write_eof() buf = client.read() self.assertEqual(buf, b'') server.close() client.close()
def test_inherit_handle(self): # Ensure that it's possible to pass a handle to the child. # Note: The "ipc" flag doubles as a read/write flag. hub = get_hub() handle = pyuv.Pipe(hub.loop, True) proc = Process() proc.spawn(python_script(['catn', '3']), extra_handles=[handle]) stream = StreamClient() stream.connect(handle) stream.write(b'Foo\n') self.assertEqual(stream.readline(), b'Foo\n') stream.write_eof() self.assertEqual(stream.readline(), b'') stream.close() proc.wait() self.assertEqual(proc.returncode, 0) proc.close()