Пример #1
0
    def _exec_file(self, args: List[str]):
        if self.need_reload:
            try:
                self.reset()
            except BaseException as ex:
                TestRun.curr_test_run.set_error_in_test(ex)

        try:
            sys.argv = [self.path_to_test] + args
            sys.path += [self.folder_to_test]
            if os.path.exists(self.folder_to_test):
                open(self.init_file, 'a').close()
            runpy.run_module(self.module_to_test, run_name="__main__")

        except ImportError as ex:
            error_text = get_stacktrace(self.path_to_test,
                                        ex,
                                        hide_internals=True)
            TestRun.curr_test_run.set_error_in_test(
                ErrorWithFeedback(error_text))

        except BaseException as ex:
            if TestRun.curr_test_run.get_error_in_test() is None:
                # ExitException is thrown in case of exit() or quit()
                # consider them like normal exit
                if not isinstance(ex, ExitException):
                    TestRun.curr_test_run.set_error_in_test(
                        ExceptionWithFeedback('', ex))

        finally:
            try:
                os.remove(self.init_file)
            except OSError:
                pass
            sys.path.pop()
Пример #2
0
    def __init__(self, test_num: int, cause: BaseException, feedback: str, stage):
        super().__init__()
        self.test_number = test_num
        self.error_text = feedback
        self.stack_trace = get_stacktrace(stage.file_to_test, cause, hide_internals=True)

        if self.stack_trace.strip().endswith('EOFError: EOF when reading a line'):
            self.error_text += '\n\nProbably your program run out of input (tried to read more than expected)'
Пример #3
0
 def __init__(self, test_num: int, cause: BaseException, stage):
     super().__init__()
     self.test_number = test_num
     self.error_text = 'We have recorded this bug ' \
                       'and will fix it soon.\n\n' + get_report()
     self.stack_trace = get_stacktrace(stage.path_to_test,
                                       cause,
                                       hide_internals=False)
Пример #4
0
 def __init__(self, test_num: int, cause: BaseException, stage):
     super().__init__()
     self.test_number = test_num
     self.error_text = get_report()
     self.stack_trace = get_stacktrace(stage.file_to_test, cause, hide_internals=False)