]> granicus.if.org Git - python/commitdiff
SF bug #1078905: Docs for unittest run() methods are misleading
authorRaymond Hettinger <python@rcn.com>
Sat, 4 Dec 2004 21:21:53 +0000 (21:21 +0000)
committerRaymond Hettinger <python@rcn.com>
Sat, 4 Dec 2004 21:21:53 +0000 (21:21 +0000)
Lib/unittest.py
Misc/NEWS

index 70645fbce5db8a2c39d7b2200b612163601acadf..efb2b025a89bf2700a3d93e617fef282bd2d4e14 100644 (file)
@@ -277,7 +277,8 @@ class TestCase:
         finally:
             result.stopTest(self)
 
-    __call__ = run
+    def __call__(self, *args, **kwds):
+        return self.run(*args, **kwds)
 
     def debug(self):
         """Run the test without collecting errors in a TestResult"""
@@ -417,15 +418,15 @@ class TestSuite:
             self.addTest(test)
 
     def run(self, result):
-        return self(result)
-
-    def __call__(self, result):
         for test in self._tests:
             if result.shouldStop:
                 break
             test(result)
         return result
 
+    def __call__(self, *args, **kwds):
+        return self.run(*args, **kwds)
+
     def debug(self):
         """Run the tests without collecting errors in a TestResult"""
         for test in self._tests: test.debug()
index 43289c9fbef11dc951c9d0cef1e2f0a3191b0a14..b20b872a452ea221f57761f890477b4ad2c435e4 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -21,6 +21,10 @@ Extension Modules
 Library
 -------
 
+- unittest.TestCase.run() and unittest.TestSuite.run() can now be successfully
+  extended or overridden by subclasses.  Formerly, the subclassed method would
+  be ignored by the rest of the module.  (Bug #1078905).
+
 - the deprecated whrandom module was removed.  Use the random module instead.
 
 - heapq.nsmallest() and heapq.nlargest() now support key= arguments with