Esempio n. 1
0
    def _discover_run(self,
                      packages,
                      argv=None,
                      missing=True,
                      one_process=False):
        # pydev friendly printing
        def formatPathPrint(path, line=None):
            if not line:
                line = 1
            path = os.path.realpath(path)
            return '  File "%r", line %d\n' % (path, line)

        #total, failed = [], []
        results = TestResults()
        # Nicer alias
        tdisc = self.test_discover
        for pkg_pth in packages:
            pkg = self._import(pkg_pth)
            #run and count
            res = tdisc.test_package(pkg, argv=argv, one_process=one_process)
            results.append_results(res)
            # Print missing
            if missing and tdisc.get_missing:
                for m in tdisc.get_missing(pkg):
                    pth = self.get_module_file(m)
                    tdisc.log('Missing test in module %s' % m)
                    tdisc.log(formatPathPrint(pth))
        # return results
        return results
Esempio n. 2
0
 def _discover_run(
         self,
         packages,
         argv=None,
         missing=True,
         one_process=False):
     # pydev friendly printing
     def formatPathPrint(path, line=None):
         if not line:
             line = 1
         path = os.path.realpath(path)
         return '  File "%r", line %d\n' % (path, line)
     #total, failed = [], []
     results = TestResults()
     # Nicer alias
     tdisc = self.test_discover
     for pkg_pth in packages:
         pkg = self._import(pkg_pth)
         #run and count
         res = tdisc.test_package(pkg, argv=argv, one_process=one_process)
         results.append_results(res)
         # Print missing
         if missing and tdisc.get_missing:
             for m in tdisc.get_missing(pkg):
                 pth = self.get_module_file(m)
                 tdisc.log('Missing test in module %s' % m)
                 tdisc.log(formatPathPrint(pth))
     # return results
     return results
Esempio n. 3
0
 def test(self, test_paths, argv=[], smoke=False):
     '''
     :param test_paths: iterable like ['package.module.test_class.test_method', ...]
     '''
     results = TestResults()
     if smoke or not test_paths:
         self.log.i('Ignoring %r \n  (smoke mode or no tests found)' %
                    list(test_paths))
         return results
     level_mngr = WebdriverManager().enter_level(level=TEST_ROUND_LIFE)
     for tpath in test_paths:
         class_ = self._import_test(tpath)
         if isinstance(class_, TestException):
             results.append_result(tpath, class_)
         else:
             result = self._run_test(tpath, argv, class_)
             results.append_result(tpath, result)
     level_mngr.exit_level()
     return results
Esempio n. 4
0
 def _run_tests(self, test_paths, argv=None, one_process=False):
     results = TestResults()
     tests = {}
     for tpath in test_paths:
         try:
             tests[tpath] = self._get_test_suite(tpath, argv)
         except Exception as e:
             results.append_result(tpath, self.reprex(e))
     result = unittest.TestResult()
     if one_process:
         suite = unittest.TestSuite(tests.values())
         self._prepare_and_run(TestsContainer(suite, result), one_process)
         results.append_result('all', result)
     else:
         for tpath, tst in tests.iteritems():
             tst = TestsContainer(tpath, argv=argv)
             if not is_pickable(tst):
                 self.log.e('Cannot pickle %r. Won\'t test it' % tst)
                 continue
             r = self._prepare_and_run(tst, one_process)
             results.append_result(tpath, r)
     return results
Esempio n. 5
0
 def _run_tests(self, test_paths, argv=None, one_process=False):
     results = TestResults()
     tests = {}
     for tpath in test_paths:
         try:
             tests[tpath] = self._get_test_suite(tpath, argv)
         except Exception as e:
             results.append_result(tpath, self.reprex(e))
     result = unittest.TestResult()
     if one_process:
         suite = unittest.TestSuite(tests.values())
         self._prepare_and_run(TestsContainer(suite, result), one_process)
         results.append_result('all', result)
     else:
         for tpath, tst in tests.iteritems():
             tst = TestsContainer(tpath, argv=argv)
             if not is_pickable(tst):
                 self.log.e('Cannot pickle %r. Won\'t test it' % tst)
                 continue
             r = self._prepare_and_run(tst, one_process)
             results.append_result(tpath, r)
     return results
Esempio n. 6
0
 def test(self, test_paths, argv=[], smoke=False):
     '''
     :param test_paths: iterable like ['package.module.test_class.test_method', ...]
     '''
     results = TestResults()
     if smoke or not test_paths:
         self.log.i('Ignoring %r \n  (smoke mode or no tests found)' %
                    list(test_paths))
         return results
     level_mngr = WebdriverManager().enter_level(level=TEST_ROUND_LIFE)
     for tpath in test_paths:
         class_ = self._import_test(tpath)
         if isinstance(class_, TestException):
             results.append_result(tpath, class_)
         else:
             result = self._run_test(tpath, argv, class_)
             results.append_result(tpath, result)
     level_mngr.exit_level()
     return results