예제 #1
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()
예제 #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()
예제 #3
0
 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)
예제 #4
0
    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)
예제 #5
0
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()
예제 #6
0
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()
예제 #7
0
 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)
예제 #8
0
 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)
예제 #9
0
 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)
예제 #10
0
    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)
예제 #11
0
 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)
예제 #12
0
    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)
예제 #13
0
    def test(self):
        def go():
            self.assertEquals(False, True)

        message_loop.post_task(go)
예제 #14
0
 def step2():
   self.assertTrue(message_loop.is_main_loop_running())
   message_loop.post_task(step3)
예제 #15
0
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()
예제 #16
0
 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())
예제 #17
0
 def test(self):
   def go():
     raise Exception("_noprint Generic error")
   message_loop.post_task(go)
예제 #18
0
 def test(self):
   def go():
     self.assertEquals(False, True)
   message_loop.post_task(go)
예제 #19
0
 def test(self):
   def go():
     self.assertEquals(True, True)
     message_loop.quit_main_loop()
   message_loop.post_task(go)
예제 #20
0
    def test(self):
        def go():
            self.assertEquals(True, True)
            message_loop.quit_main_loop()

        message_loop.post_task(go)
예제 #21
0
 def step2():
     self.assertTrue(message_loop.is_main_loop_running())
     message_loop.post_task(step3)
예제 #22
0
    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())
예제 #23
0
    def test(self):
        def go():
            raise Exception("_noprint Generic error")

        message_loop.post_task(go)