Exemplo n.º 1
0
    def async_run_testcase(self, result):
        result.startTest(self)
        testMethod = getattr(self, self._method_name)
        self._num_failures_at_start = len(result.failures)
        self._num_errors_at_start = len(result.errors)

        try:
            self.setUp()
        except KeyboardInterrupt:
            raise
        except:
            result.addError(self, self._exc_info())
            self.async_teardown_and_stop_test(result, tearDown=False)
            return

        ok = False
        try:
            testMethod()
            ok = True
        except self.failureException:
            result.addFailure(self, self._exc_info())
            self.async_teardown_and_stop_test(result)
        except KeyboardInterrupt:
            self.async_teardown_and_stop_test(result)
            raise
        except:
            result.addError(self, self._exc_info())
            self.async_teardown_and_stop_test(result)

        def do_async_teardown_and_stop_test():
            self.async_teardown_and_stop_test(result)

        message_loop.add_quit_handler(do_async_teardown_and_stop_test)
Exemplo n.º 2
0
def main(parser):
    parser.add_option("--module", dest="module")
    parser.add_option("--class", dest="cls")
    parser.add_option("--method", dest="method")
    parser.add_option("--result", dest="result")
    (options, args) = parser.parse_args()

    mod = __import__(options.module, {}, {}, fromlist=[True])
    cls = getattr(mod, options.cls)
    test = cls(options.method, is_in_slave=True)
    result = unittest.TestResult()
    _output_ran = []

    def output_result():
        f = open(options.result, "w")
        s = repr(
            {
                "testsRun": result.testsRun,
                "errors": [e for t, e in result.errors],
                "failures": [e for t, e in result.failures],
                "shouldStop": result.shouldStop,
            }
        )
        f.write(s)
        f.close()
        _output_ran.append(True)

    message_loop.add_quit_handler(output_result)

    def do_test():
        message_loop.set_unittests_running(True)
        test.run(result)

    message_loop.post_task(do_test)
    message_loop.run_main_loop()
Exemplo n.º 3
0
    def async_run_testcase(self, result):
        result.startTest(self)
        testMethod = getattr(self, self._method_name)
        self._num_failures_at_start = len(result.failures)
        self._num_errors_at_start = len(result.errors)

        try:
            self.setUp()
        except KeyboardInterrupt:
            raise
        except:
            result.addError(self, sys.exc_info())
            self.async_teardown_and_stop_test(result, tearDown=False)
            return

        ok = False
        try:
            testMethod()
            ok = True
        except self.failureException:
            result.addFailure(self, sys.exc_info())
            self.async_teardown_and_stop_test(result)
        except KeyboardInterrupt:
            self.async_teardown_and_stop_test(result)
            raise
        except:
            result.addError(self, sys.exc_info())
            self.async_teardown_and_stop_test(result)

        def do_async_teardown_and_stop_test():
            self.async_teardown_and_stop_test(result)

        message_loop.add_quit_handler(do_async_teardown_and_stop_test)
Exemplo n.º 4
0
def main(parser):
    parser.add_option("--module", dest="module")
    parser.add_option("--class", dest="cls")
    parser.add_option("--method", dest="method")
    parser.add_option("--result", dest="result")
    (options, args) = parser.parse_args()

    mod = __import__(options.module, {}, {}, fromlist=[True])
    cls = getattr(mod, options.cls)
    test = cls(options.method, is_in_slave=True)
    result = unittest.TestResult()
    _output_ran = []

    def output_result():
        f = open(options.result, 'w')
        s = repr({
            "testsRun": result.testsRun,
            "errors": [e for t, e in result.errors],
            "failures": [e for t, e in result.failures],
            "shouldStop": result.shouldStop
        })
        f.write(s)
        f.close()
        _output_ran.append(True)

    message_loop.add_quit_handler(output_result)

    def do_test():
        message_loop.set_unittests_running(True)
        test.run(result)

    message_loop.post_task(do_test)
    message_loop.run_main_loop()
Exemplo n.º 5
0
    def edit_at_quit(filenames, canceled):
        def do_edit():
            edit(filenames, canceled)

        message_loop.add_quit_handler(do_edit)
Exemplo n.º 6
0
 def edit_at_quit(filenames, canceled):
   def do_edit():
     edit(filenames, canceled)
   message_loop.add_quit_handler(do_edit)