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())