예제 #1
0
def FunctionWithExceptions(funcname, calls):
    execution = EmptyProjectExecution()
    function = Function(funcname, sorted(calls[0][0].keys()))
    function.calls = [FunctionCall(function,
                                   stable_serialize_call_arguments(execution, i),
                                   exception=execution.serialize(e)) for (i,e) in calls]
    return function
예제 #2
0
    def test_generates_imports_for_user_defined_exceptions(self):
        klass = Class("UserDefinedException")
        function = Function("throw")
        function.calls = [FunctionCall(function, {}, exception=UserObject(None, klass))]

        result = generate_single_test_module(objects=[function, klass])

        assert_contains(result, "from module import UserDefinedException")
예제 #3
0
def FunctionWithCalls(funcname, calls):
    def fc(function, args, output, execution):
        call = FunctionCall(function, stable_serialize_call_arguments(execution, args))
        # Output needs to be created after the Call object is created.
        call.set_output(execution.serialize(output))
        return call
    execution = EmptyProjectExecution()
    function = Function(funcname, sorted(calls[0][0].keys()))
    function.calls = [fc(function, i, o, execution) for (i,o) in calls]
    return function