示例#1
0
 def test_timing(self):
     options = MockOptions(verbose=0, timing=True)
     stream = StringIO.StringIO()
     loader = FakeLoader(('test1 (Foo)', '.', ''),
                         ('test2 (Foo)', 'F', 'test2\nfailed'),
                         ('test3 (Foo)', 'E', 'test3\nerred'))
     result = TestRunner(stream, options, loader).run(loader.top_suite())
     self.assertFalse(result.wasSuccessful())
     self.assertEquals(result.testsRun, 3)
     self.assertEquals(len(result.failures), 1)
     self.assertEquals(len(result.errors), 1)
示例#2
0
        for name in names:
            if self.finder.is_module(name):
                # if we failed to load a name and it looks like a module,
                # try importing it directly, because loadTestsFromName()
                # produces lousy error messages for bad modules.
                try:
                    __import__(name)
                except ImportError, e:
                    _log.fatal('Failed to import %s:' % name)
                    self._log_exception()
                    return False

            suites.append(loader.loadTestsFromName(name, None))

        test_suite = unittest.TestSuite(suites)
        test_runner = TestRunner(self.stream, self._options, loader)

        _log.debug("Running the tests.")
        result = test_runner.run(test_suite)
        if self._options.coverage:
            cov.stop()
            cov.save()
            cov.report(show_missing=False)
        return result.wasSuccessful()

    def _log_exception(self):
        s = StringIO.StringIO()
        traceback.print_exc(file=s)
        for l in s.buflist:
            _log.error('  ' + l.rstrip())
示例#3
0
文件: main.py 项目: dzhshf/WebKit
        for name in names:
            if self.finder.is_module(name):
                # if we failed to load a name and it looks like a module,
                # try importing it directly, because loadTestsFromName()
                # produces lousy error messages for bad modules.
                try:
                    __import__(name)
                except ImportError, e:
                    _log.fatal('Failed to import %s:' % name)
                    self._log_exception()
                    return False

            suites.append(loader.loadTestsFromName(name, None))

        test_suite = unittest.TestSuite(suites)
        test_runner = TestRunner(self.stream, self._options, loader)

        _log.debug("Running the tests.")
        result = test_runner.run(test_suite)
        if self._options.coverage:
            cov.stop()
            cov.save()
            cov.report(show_missing=False)
        return result.wasSuccessful()

    def _log_exception(self):
        s = StringIO.StringIO()
        traceback.print_exc(file=s)
        for l in s.buflist:
            _log.error('  ' + l.rstrip())