summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-12-04 21:21:53 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-12-04 21:21:53 (GMT)
commit664347be946f0a217f91259f93962727ba84c287 (patch)
tree7bba038f5dfc1ef6f5d7c1b2d8de2fad6ff5d3cb
parent46ea4c810fdce135189d1835b6cb99d6d8bf7738 (diff)
downloadcpython-664347be946f0a217f91259f93962727ba84c287.zip
cpython-664347be946f0a217f91259f93962727ba84c287.tar.gz
cpython-664347be946f0a217f91259f93962727ba84c287.tar.bz2
SF bug #1078905: Docs for unittest run() methods are misleading
-rw-r--r--Lib/unittest.py9
-rw-r--r--Misc/NEWS4
2 files changed, 9 insertions, 4 deletions
diff --git a/Lib/unittest.py b/Lib/unittest.py
index 70645fb..efb2b02 100644
--- a/Lib/unittest.py
+++ b/Lib/unittest.py
@@ -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()
diff --git a/Misc/NEWS b/Misc/NEWS
index 43289c9..b20b872 100644
--- 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