def test():
    a, b = socket.socketpair()
    ma = Messaging(a)
    mb = Messaging(b)
    assert ma.wait(0) is None
    mb.send(['foo'])
    ret = ma.wait()
    assert ret == ['foo'], ret
def test_closed_remote_wait():
    a, b = socket.socketpair()
    ma = Messaging(a)
    mb = Messaging(b)

    # send a message for luck.
    mb.send('message')
    assert ma.wait() == 'message'
    b.close()
    ma.wait()
def test_closed_socket_wait():
    # trigger an EBADF
    a, b = socket.socketpair()
    ma = Messaging(a)
    mb = Messaging(b)

    # send a message for luck.
    ma.send('message')
    assert mb.wait() == 'message'
    a.close()
    ma.send('another message')
def test_closed_remote_send():
    # trigger an EPIPE
    a, b = socket.socketpair()
    ma = Messaging(a)
    mb = Messaging(b)

    # send a message for luck.
    ma.send('message')
    assert mb.wait() == 'message'
    b.close()
    ma.send('another message')