예제 #1
0
    def test_trace_includes_rule_exception_traceback(self):
        # Execute a request that will trigger the nested raise, and then directly inspect its trace.
        request = self.scheduler.execution_request([A], [B()])
        _, throws = self.scheduler.execute(request)

        with self.assertRaises(ExecutionError) as cm:
            self.scheduler._raise_on_error([t for _, t in throws])

        trace = remove_locations_from_traceback(str(cm.exception))
        assert_equal_with_printing(
            self,
            dedent("""\
                 1 Exception encountered:

                 Engine traceback:
                   in Nested raise
                 Traceback (most recent call last):
                   File LOCATION-INFO, in nested_raise
                     fn_raises(x)
                   File LOCATION-INFO, in fn_raises
                     raise Exception(f"An exception for {type(x).__name__}")
                 Exception: An exception for B
                 """),
            trace,
        )
예제 #2
0
    def test_trace_includes_rule_exception_traceback(self):
        # Execute a request that will trigger the nested raise, and then directly inspect its trace.
        request = self.scheduler.execution_request([A], [B()])
        self.scheduler.execute(request)

        trace = remove_locations_from_traceback("\n".join(self.scheduler.trace(request)))
        assert_equal_with_printing(
            self,
            dedent(
                f"""\
                Computing Select(B(), A)
                  Computing Task({fmt_rust_function(nested_raise)}(), B(), A, true)
                    Throw(An exception for B)
                      Traceback (most recent call last):
                        File LOCATION-INFO, in call
                          val = func(*args)
                        File LOCATION-INFO, in nested_raise
                          fn_raises(x)
                        File LOCATION-INFO, in fn_raises
                          raise Exception(f"An exception for {{type(x).__name__}}")
                      Exception: An exception for B"""
            )
            + "\n\n",  # Traces include two empty lines after.
            trace,
        )
예제 #3
0
def assert_equal_graph_output(test_case, expected, actual):
    return assert_equal_with_printing(
        test_case,
        expected,
        actual,
        uniform_formatter=remove_whitespace_from_graph_output)