]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport 1.8, 1.9
authorAnthony Baxter <anthonybaxter@gmail.com>
Wed, 5 Dec 2001 06:30:21 +0000 (06:30 +0000)
committerAnthony Baxter <anthonybaxter@gmail.com>
Wed, 5 Dec 2001 06:30:21 +0000 (06:30 +0000)
--
patch 418489 from Andrew Dalke for string format bug
--
Merged in bugfix from PyUnit CVS for problem reported by Gary Todd.
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.)
--

Lib/unittest.py

index 72414fa3887cd7d0e28bc2e89a7ae7e91c21c689..480e825d58072a40cff85cfd6d8f2b4af7ba0290 100644 (file)
@@ -432,18 +432,19 @@ 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
+                      "calling %s returned %s, not a test" % (obj,test)
             return test
         else:
             raise ValueError, "don't know how to make test from: %s" % obj