Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
bbea35f1
Commit
bbea35f1
authored
Nov 01, 2010
by
Michael Foord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue 9926. TestSuite subclasses that override __call__ are called correctly.
parent
e6fa3811
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
19 deletions
+32
-19
Lib/unittest/result.py
Lib/unittest/result.py
+1
-0
Lib/unittest/suite.py
Lib/unittest/suite.py
+17
-19
Lib/unittest/test/test_suite.py
Lib/unittest/test/test_suite.py
+14
-0
No files found.
Lib/unittest/result.py
View file @
bbea35f1
...
...
@@ -34,6 +34,7 @@ class TestResult(object):
formatted traceback of the error that occurred.
"""
_previousTestClass
=
None
_testRunEntered
=
False
_moduleSetUpFailed
=
False
def
__init__
(
self
,
stream
=
None
,
descriptions
=
None
,
verbosity
=
None
):
self
.
failfast
=
False
...
...
Lib/unittest/suite.py
View file @
bbea35f1
...
...
@@ -77,23 +77,11 @@ class TestSuite(BaseTestSuite):
subclassing, do not forget to call the base class constructor.
"""
def
run
(
self
,
result
,
debug
=
False
):
topLevel
=
False
if
getattr
(
result
,
'_testRunEntered'
,
False
)
is
False
:
result
.
_testRunEntered
=
topLevel
=
True
def
run
(
self
,
result
):
self
.
_wrapped_run
(
result
)
self
.
_tearDownPreviousClass
(
None
,
result
)
self
.
_handleModuleTearDown
(
result
)
return
result
def
debug
(
self
):
"""Run the tests without collecting errors in a TestResult"""
debug
=
_DebugResult
()
self
.
_wrapped_run
(
debug
,
True
)
self
.
_tearDownPreviousClass
(
None
,
debug
)
self
.
_handleModuleTearDown
(
debug
)
################################
# private methods
def
_wrapped_run
(
self
,
result
,
debug
=
False
):
for
test
in
self
:
if
result
.
shouldStop
:
break
...
...
@@ -108,13 +96,23 @@ class TestSuite(BaseTestSuite):
getattr
(
result
,
'_moduleSetUpFailed'
,
False
)):
continue
if
hasattr
(
test
,
'_wrapped_run'
):
test
.
_wrapped_run
(
result
,
debug
)
elif
not
debug
:
if
not
debug
:
test
(
result
)
else
:
test
.
debug
()
if
topLevel
:
self
.
_tearDownPreviousClass
(
None
,
result
)
self
.
_handleModuleTearDown
(
result
)
return
result
def
debug
(
self
):
"""Run the tests without collecting errors in a TestResult"""
debug
=
_DebugResult
()
self
.
run
(
debug
,
True
)
################################
def
_handleClassSetUp
(
self
,
test
,
result
):
previousClass
=
getattr
(
result
,
'_previousTestClass'
,
None
)
currentClass
=
test
.
__class__
...
...
Lib/unittest/test/test_suite.py
View file @
bbea35f1
...
...
@@ -345,5 +345,19 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
self
.
assertEqual
(
result
.
testsRun
,
2
)
def
test_overriding_call
(
self
):
class
MySuite
(
unittest
.
TestSuite
):
called
=
False
def
__call__
(
self
,
*
args
,
**
kw
):
self
.
called
=
True
unittest
.
TestSuite
.
__call__
(
self
,
*
args
,
**
kw
)
suite
=
MySuite
()
wrapper
=
unittest
.
TestSuite
()
wrapper
.
addTest
(
suite
)
wrapper
(
unittest
.
TestResult
())
self
.
assertTrue
(
suite
.
called
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment