From 80367c45f021f20f687cb1710498f707fe0b1b99 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sat, 4 Dec 2004 21:24:19 +0000 Subject: [PATCH] SF bug #1078905: Docs for unittest run() methods are misleading --- Lib/unittest.py | 9 +++++---- Misc/NEWS | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Lib/unittest.py b/Lib/unittest.py index 70645fbce5db..efb2b025a89b 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 4411d858854c..afc742fa2d1f 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -15,6 +15,11 @@ Core and builtins 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). + + Build ----- -- 2.47.3