mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
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
This commit is contained in:
parent
1d22d00e97
commit
37d89a2955
1 changed files with 4 additions and 4 deletions
|
@ -998,7 +998,7 @@ class TestSuite(object):
|
||||||
self.addTests(tests)
|
self.addTests(tests)
|
||||||
|
|
||||||
def __repr__(self):
|
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):
|
def __eq__(self, other):
|
||||||
if not isinstance(other, self.__class__):
|
if not isinstance(other, self.__class__):
|
||||||
|
@ -1016,7 +1016,7 @@ class TestSuite(object):
|
||||||
|
|
||||||
def countTestCases(self):
|
def countTestCases(self):
|
||||||
cases = 0
|
cases = 0
|
||||||
for test in self._tests:
|
for test in self:
|
||||||
cases += test.countTestCases()
|
cases += test.countTestCases()
|
||||||
return cases
|
return cases
|
||||||
|
|
||||||
|
@ -1036,7 +1036,7 @@ class TestSuite(object):
|
||||||
self.addTest(test)
|
self.addTest(test)
|
||||||
|
|
||||||
def run(self, result):
|
def run(self, result):
|
||||||
for test in self._tests:
|
for test in self:
|
||||||
if result.shouldStop:
|
if result.shouldStop:
|
||||||
break
|
break
|
||||||
test(result)
|
test(result)
|
||||||
|
@ -1047,7 +1047,7 @@ class TestSuite(object):
|
||||||
|
|
||||||
def debug(self):
|
def debug(self):
|
||||||
"""Run the tests without collecting errors in a TestResult"""
|
"""Run the tests without collecting errors in a TestResult"""
|
||||||
for test in self._tests:
|
for test in self:
|
||||||
test.debug()
|
test.debug()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue