def test_synchronous_executor():
    executor = SynchronousExecutor()

    assert executor.submit(lambda: mock.sentinel.RESULT).result() is mock.sentinel.RESULT

    def callable():
        raise Exception(mock.sentinel.EXCEPTION)

    future = executor.submit(callable)
    try:
        future.result()
    except Exception as e:
        assert e.args[0] == mock.sentinel.EXCEPTION
    else:
        assert False, "expected future to raise"
Beispiel #2
0
def test_sychronous_executor():
    executor = SynchronousExecutor()

    assert executor.submit(lambda: mock.sentinel.RESULT).result() is mock.sentinel.RESULT

    def callable():
        raise Exception(mock.sentinel.MESSAGE)

    future = executor.submit(callable)
    try:
        future.result()
    except Exception as e:
        assert e.message is mock.sentinel.MESSAGE
    else:
        assert False, 'expected future to raise'
Beispiel #3
0
def test_sychronous_executor():
    executor = SynchronousExecutor()

    assert executor.submit(
        lambda: mock.sentinel.RESULT).result() is mock.sentinel.RESULT

    def callable():
        raise Exception(mock.sentinel.MESSAGE)

    future = executor.submit(callable)
    try:
        future.result()
    except Exception as e:
        assert e.message is mock.sentinel.MESSAGE
    else:
        assert False, 'expected future to raise'
Beispiel #4
0
def delegator() -> Delegator:
    executor = SynchronousExecutor()
    return Delegator(
        Operation,
        {
            "add": (Add(), executor),
            "sub": (Sub(), executor),
            "error": (Error(), executor)
        },
        Mock(),
        Mock(),
    )