summaryrefslogtreecommitdiff
path: root/Lib/unittest.py
diff options
context:
space:
mode:
authorMichael Foord <fuzzyman@voidspace.org.uk>2009-04-05 01:15:01 +0000
committerMichael Foord <fuzzyman@voidspace.org.uk>2009-04-05 01:15:01 +0000
commit37d89a295540bb56e230a4935912f0fe5bdd0301 (patch)
treea5f4849bb76a803bea898e181911d464e0a33f57 /Lib/unittest.py
parent1d22d00e97f62c79c58b03603824aa254d712708 (diff)
downloadcpython-git-37d89a295540bb56e230a4935912f0fe5bdd0301.tar.gz
Change the way unittest.TestSuite use their tests to always access them through iteration. Non behavior changing, this allows you to create custom subclasses that override __iter__.
Issue #5693
Diffstat (limited to 'Lib/unittest.py')
-rw-r--r--Lib/unittest.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/unittest.py b/Lib/unittest.py
index 3eedd56511..83790fce70 100644
--- a/Lib/unittest.py
+++ b/Lib/unittest.py
@@ -998,7 +998,7 @@ class TestSuite(object):
self.addTests(tests)
def __repr__(self):
- return "<%s tests=%s>" % (_strclass(self.__class__), self._tests)
+ return "<%s tests=%s>" % (_strclass(self.__class__), list(self))
def __eq__(self, other):
if not isinstance(other, self.__class__):
@@ -1016,7 +1016,7 @@ class TestSuite(object):
def countTestCases(self):
cases = 0
- for test in self._tests:
+ for test in self:
cases += test.countTestCases()
return cases
@@ -1036,7 +1036,7 @@ class TestSuite(object):
self.addTest(test)
def run(self, result):
- for test in self._tests:
+ for test in self:
if result.shouldStop:
break
test(result)
@@ -1047,7 +1047,7 @@ class TestSuite(object):
def debug(self):
"""Run the tests without collecting errors in a TestResult"""
- for test in self._tests:
+ for test in self:
test.debug()