def test_reader_read_error(): server, client = socket.socketpair() reader = connection.Reader(IOStream(server)) writer = connection.Writer(IOStream(client)) yield writer.put(messages.PingRequestMessage()) ping = yield reader.get() assert isinstance(ping, messages.PingRequestMessage) reader.io_stream.close() future = reader.get() with pytest.raises(StreamClosedError): yield future
def test_writer_write_error(): server, client = socket.socketpair() reader = connection.Reader(IOStream(server)) writer = connection.Writer(IOStream(client)) # one successful message first yield writer.put(messages.PingRequestMessage()) ping = yield reader.get() assert isinstance(ping, messages.PingRequestMessage) writer.io_stream.close() with pytest.raises(StreamClosedError): yield writer.put(messages.PingResponseMessage())
def test_valid_ping_request(): """Verify we don't barf on 0-length bodies.""" assert (messages.ping_req_rw.read( BytesIO()) == messages.PingRequestMessage())