예제 #1
0
def test_read_timeout():
    mocked_socket = mock.Mock()
    mocked_socket.recv.side_effect = mod.socket.timeout

    try:
        mod.read(mocked_socket)
        assert False, 'Timeout was expected'
    except socket.timeout:
        pass
예제 #2
0
파일: test_ipc.py 프로젝트: cyoung/ondd-ipc
def test_read_timeout():
    mocked_socket = mock.Mock()
    mocked_socket.recv.side_effect = mod.socket.timeout

    try:
        mod.read(mocked_socket)
        assert False, 'Timeout was expected'
    except socket.timeout:
        pass
예제 #3
0
def test_read_success():
    data = 'something'

    def mocked_recv(size):
        if hasattr(mocked_recv, 'called'):
            return '\0'

        mocked_recv.called = True
        return data

    mocked_socket = mock.Mock()
    mocked_socket.recv.side_effect = mocked_recv

    result = mod.read(mocked_socket)
    assert result == data
예제 #4
0
파일: test_ipc.py 프로젝트: cyoung/ondd-ipc
def test_read_success():
    data = 'something'

    def mocked_recv(size):
        if hasattr(mocked_recv, 'called'):
            return '\0'

        mocked_recv.called = True
        return data

    mocked_socket = mock.Mock()
    mocked_socket.recv.side_effect = mocked_recv

    result = mod.read(mocked_socket)
    assert result == data