]> granicus.if.org Git - python/commitdiff
Merged in bugfix from PyUnit CVS for problem reported by Gary Todd.
authorSteve Purcell <steve@pythonconsulting.com>
Wed, 8 Aug 2001 07:57:26 +0000 (07:57 +0000)
committerSteve Purcell <steve@pythonconsulting.com>
Wed, 8 Aug 2001 07:57:26 +0000 (07:57 +0000)
If 'unittest.py' was run from the command line with the name of a test
case class as a parameter, it failed with an ugly error. (Which was a
shame, because the documentation says you can do that.)

The problem was the old 'is the class X that you imported from me the same
as my class X?' gotcha.

Lib/unittest.py

index c3faa10e3fcec36f1493880ded35ed06dafcd4df..480e825d58072a40cff85cfd6d8f2b4af7ba0290 100644 (file)
@@ -432,16 +432,17 @@ class TestLoader:
         for part in parts:
             obj = getattr(obj, part)
 
+        import unittest
         if type(obj) == types.ModuleType:
             return self.loadTestsFromModule(obj)
-        elif type(obj) == types.ClassType and issubclass(obj, TestCase):
+        elif type(obj) == types.ClassType and issubclass(obj, unittest.TestCase):
             return self.loadTestsFromTestCase(obj)
         elif type(obj) == types.UnboundMethodType:
             return obj.im_class(obj.__name__)
         elif callable(obj):
             test = obj()
-            if not isinstance(test, TestCase) and \
-               not isinstance(test, TestSuite):
+            if not isinstance(test, unittest.TestCase) and \
+               not isinstance(test, unittest.TestSuite):
                 raise ValueError, \
                       "calling %s returned %s, not a test" % (obj,test)
             return test