def test_memory_connect(self):
    '\n        Two `Connection`s which use memory BIOs can be manually connected by\n        reading from the output of each and writing those bytes to the input of\n        the other and in this way establish a connection and exchange\n        application-level bytes with each other.\n        '
    server_conn = self._server(None)
    client_conn = self._client(None)
    assert (server_conn.master_key() is None)
    assert (server_conn.client_random() is None)
    assert (server_conn.server_random() is None)
    assert (interact_in_memory(client_conn, server_conn) is None)
    assert (server_conn.master_key() is not None)
    assert (server_conn.client_random() is not None)
    assert (server_conn.server_random() is not None)
    assert (server_conn.client_random() == client_conn.client_random())
    assert (server_conn.server_random() == client_conn.server_random())
    assert (server_conn.client_random() != server_conn.server_random())
    assert (client_conn.client_random() != client_conn.server_random())
    cekm = client_conn.export_keying_material(b'LABEL', 32)
    sekm = server_conn.export_keying_material(b'LABEL', 32)
    assert (cekm is not None)
    assert (sekm is not None)
    assert (cekm == sekm)
    assert (len(sekm) == 32)
    cekmc = client_conn.export_keying_material(b'LABEL', 32, b'CONTEXT')
    sekmc = server_conn.export_keying_material(b'LABEL', 32, b'CONTEXT')
    assert (cekmc is not None)
    assert (sekmc is not None)
    assert (cekmc == sekmc)
    assert (cekmc != cekm)
    assert (sekmc != sekm)
    cekmt = client_conn.export_keying_material(b'test', 32, b'CONTEXT')
    sekmt = server_conn.export_keying_material(b'test', 32, b'CONTEXT')
    assert (cekmc != cekmt)
    assert (sekmc != sekmt)
    important_message = b'One if by land, two if by sea.'
    server_conn.write(important_message)
    assert (interact_in_memory(client_conn, server_conn) == (client_conn, important_message))
    client_conn.write(important_message[::(- 1)])
    assert (interact_in_memory(client_conn, server_conn) == (server_conn, important_message[::(- 1)]))
Two `Connection`s which use memory BIOs can be manually connected by
reading from the output of each and writing those bytes to the input of
the other and in this way establish a connection and exchange
application-level bytes with each other.
def test_memory_connect(self):
    '\n        Two `Connection`s which use memory BIOs can be manually connected by\n        reading from the output of each and writing those bytes to the input of\n        the other and in this way establish a connection and exchange\n        application-level bytes with each other.\n        '
    server_conn = self._server(None)
    client_conn = self._client(None)
    assert (server_conn.master_key() is None)
    assert (server_conn.client_random() is None)
    assert (server_conn.server_random() is None)
    assert (interact_in_memory(client_conn, server_conn) is None)
    assert (server_conn.master_key() is not None)
    assert (server_conn.client_random() is not None)
    assert (server_conn.server_random() is not None)
    assert (server_conn.client_random() == client_conn.client_random())
    assert (server_conn.server_random() == client_conn.server_random())
    assert (server_conn.client_random() != server_conn.server_random())
    assert (client_conn.client_random() != client_conn.server_random())
    cekm = client_conn.export_keying_material(b'LABEL', 32)
    sekm = server_conn.export_keying_material(b'LABEL', 32)
    assert (cekm is not None)
    assert (sekm is not None)
    assert (cekm == sekm)
    assert (len(sekm) == 32)
    cekmc = client_conn.export_keying_material(b'LABEL', 32, b'CONTEXT')
    sekmc = server_conn.export_keying_material(b'LABEL', 32, b'CONTEXT')
    assert (cekmc is not None)
    assert (sekmc is not None)
    assert (cekmc == sekmc)
    assert (cekmc != cekm)
    assert (sekmc != sekm)
    cekmt = client_conn.export_keying_material(b'test', 32, b'CONTEXT')
    sekmt = server_conn.export_keying_material(b'test', 32, b'CONTEXT')
    assert (cekmc != cekmt)
    assert (sekmc != sekmt)
    important_message = b'One if by land, two if by sea.'
    server_conn.write(important_message)
    assert (interact_in_memory(client_conn, server_conn) == (client_conn, important_message))
    client_conn.write(important_message[::(- 1)])
    assert (interact_in_memory(client_conn, server_conn) == (server_conn, important_message[::(- 1)]))