Merge branch 'master' of https://github.com/markflorisson88/cython into markflorisson...
authorRobert Bradshaw <robertwb@math.washington.edu>
Fri, 14 Jan 2011 07:54:47 +0000 (23:54 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Fri, 14 Jan 2011 07:54:47 +0000 (23:54 -0800)
1  2 
runtests.py

diff --cc runtests.py
index 004b0493ee88cd2a320be20130e5ca1e46f99983,2376a295048375f09d3a6e464dbe27dc66275b75..92252f16322d8cd4731a43523fd4d07a22680069
@@@ -630,57 -625,31 +630,57 @@@ class CythonUnitTestCase(CythonRunTestC
      def shortDescription(self):
          return "compiling (%s) tests in %s" % (self.language, self.module)
  
 -    def run(self, result=None):
 -        if result is None:
 -            result = self.defaultTestResult()
 -        result.startTest(self)
 +    def run_tests(self, result):
 +        unittest.defaultTestLoader.loadTestsFromName(self.module).run(result)
 +
 +
 +class CythonPyregrTestCase(CythonRunTestCase):
 +    def _run_unittest(self, result, *classes):
 +        """Run tests from unittest.TestCase-derived classes."""
 +        valid_types = (unittest.TestSuite, unittest.TestCase)
 +        suite = unittest.TestSuite()
 +        for cls in classes:
 +            if isinstance(cls, str):
 +                if cls in sys.modules:
 +                    suite.addTest(unittest.findTestCases(sys.modules[cls]))
 +                else:
 +                    raise ValueError("str arguments must be keys in sys.modules")
 +            elif isinstance(cls, valid_types):
 +                suite.addTest(cls)
 +            else:
 +                suite.addTest(unittest.makeSuite(cls))
 +        suite.run(result)
 +
 +    def _run_doctest(self, result, module):
 +        self.run_doctests(module, result)
 +
 +    def run_tests(self, result):
          try:
 -            self.setUp()
 -            try:
 -                self.runCompileTest()
 -                unittest.defaultTestLoader.loadTestsFromName(self.module).run(result)
 -            finally:
 -                check_thread_termination()
 -        except Exception:
 -            result.addError(self, sys.exc_info())
 -            result.stopTest(self)
 +            from test import test_support as support
 +        except ImportError: # Py3k
 +            from test import support
 +
 +        def run_unittest(*classes):
 +            return self._run_unittest(result, *classes)
 +        def run_doctest(module, verbosity=None):
 +            return self._run_doctest(result, module)
 +
 +        support.run_unittest = run_unittest
 +        support.run_doctest = run_doctest
 +
          try:
 -            self.tearDown()
 -        except Exception:
 -            pass
 +            module = __import__(self.module)
 +            if hasattr(module, 'test_main'):
 +                module.test_main()
 +        except (unittest.SkipTest, support.ResourceDenied):
 +            result.addSkip(self, 'ok')
  
- try:
-     import gdb
-     include_debugger = sys.version_info[:2] > (2, 5)
- except:
-     include_debugger = False
+ # Someone wrapped this in a:
+ # 'try: import gdb; ... except: include_debugger = False' thing, but don't do 
+ # this, it doesn't work as gdb is a builtin module in GDB. The tests themselves
+ # are doing the skipping. If there's a problem with the tests, please file an 
+ # issue.
+ include_debugger = sys.version_info[:2] > (2, 5)
  
  def collect_unittests(path, module_prefix, suite, selectors):
      def file_matches(filename):