diff options
author | Michael Foord <fuzzyman@voidspace.org.uk> | 2011-01-03 17:00:11 (GMT) |
---|---|---|
committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2011-01-03 17:00:11 (GMT) |
commit | 32e1d8340c05fa62ba51dbd942bdc09a21e65f6e (patch) | |
tree | 4523249e3c25efec0cc94a82a9392894282d3990 /Lib/unittest/case.py | |
parent | faa8c13ef43eda21a363524a7eb0ff1b361bbe67 (diff) | |
download | cpython-32e1d8340c05fa62ba51dbd942bdc09a21e65f6e.zip cpython-32e1d8340c05fa62ba51dbd942bdc09a21e65f6e.tar.gz cpython-32e1d8340c05fa62ba51dbd942bdc09a21e65f6e.tar.bz2 |
Enable unittest.TestCase to be instantiated without providing a method name.
Changed unittestgui to show number of discovered tests in the status bar.
Diffstat (limited to 'Lib/unittest/case.py')
-rw-r--r-- | Lib/unittest/case.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index 004a9f5..0277ac8 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -274,12 +274,17 @@ class TestCase(object): """ self._testMethodName = methodName self._outcomeForDoCleanups = None + self._testMethodDoc = 'No test' try: testMethod = getattr(self, methodName) except AttributeError: - raise ValueError("no such test method in %s: %s" % - (self.__class__, methodName)) - self._testMethodDoc = testMethod.__doc__ + if methodName != 'runTest': + # we allow instantiation with no explicit method name + # but not an *incorrect* or missing method name + raise ValueError("no such test method in %s: %s" % + (self.__class__, methodName)) + else: + self._testMethodDoc = testMethod.__doc__ self._cleanups = [] # Map types to custom assertEqual functions that will compare |