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()
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()
def run(self, result): def do_test(): self.async_run_testcase(result) message_loop.post_task(do_test) message_loop.set_active_test(self, result) message_loop.run_main_loop() message_loop.set_active_test(None, None)
def run(options, db, initial_filter, print_results_cb = None): def go(): dlg = OpenDialog(options, db, initial_filter) if print_results_cb: dlg.print_results_cb = print_results_cb message_loop.post_task(go) message_loop.run_main_loop()
def run(options, db, initial_filter, print_results_cb=None): def go(): dlg = OpenDialog(options, db, initial_filter) if print_results_cb: dlg.print_results_cb = print_results_cb message_loop.post_task(go) message_loop.run_main_loop()
def test_post_two_tasks(self): def step2(): self.assertTrue(message_loop.is_main_loop_running()) message_loop.post_task(step3) def step3(): self.assertTrue(message_loop.is_main_loop_running()) message_loop.quit_main_loop() message_loop.post_task(step2)
def __init__(self, options, db, initial_filter): manifest_file = os.path.join(os.path.dirname(__file__), 'chrome_app', 'manifest.json') self.app = chromeapp.App('quickopen', manifest_file) self.print_results_cb = None # This postTask is needed because OpenDialog's base class assigns # print_results_cb after we return from the constructor, assuming # that the message loop is running. Le sigh. message_loop.post_task(self.Run, options, db, initial_filter)
def run(self, result): if sys.platform == 'darwin' and '--objc' in sys.argv: if not self._is_in_slave: return self.run_darwin(result) else: assert message_loop.is_main_loop_running() message_loop.set_active_test(self, result) self.async_run_testcase(result) else: def do_test(): self.async_run_testcase(result) message_loop.post_task(do_test) message_loop.set_active_test(self, result) message_loop.run_main_loop() message_loop.set_active_test(None, None)
def test(self): def go(): self.assertEquals(False, True) message_loop.post_task(go)
def step2(): self.assertTrue(message_loop.is_main_loop_running()) message_loop.post_task(step3)
def run(settings, options, db, initial_filter): def go(): OpenDialog(settings, options, db, initial_filter) message_loop.post_task(go) message_loop.run_main_loop()
def test_message_loop_wont_run_in_regular_testcase(self): def shouldnt_run(): raise Exception("Shouldn't ever get here") message_loop.post_task(shouldnt_run) self.assertRaises(Exception, lambda: message_loop.run_main_loop())
def test(self): def go(): raise Exception("_noprint Generic error") message_loop.post_task(go)
def test(self): def go(): self.assertEquals(True, True) message_loop.quit_main_loop() message_loop.post_task(go)