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
90932848
Commit
90932848
authored
Jan 20, 2014
by
Gregory P. Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes Issue #20165: The unittest module no longer considers tests marked with
@expectedFailure successful if they pass.
parent
242c3810
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
5 deletions
+17
-5
Doc/library/unittest.rst
Doc/library/unittest.rst
+4
-0
Lib/unittest/result.py
Lib/unittest/result.py
+8
-3
Lib/unittest/test/test_skipping.py
Lib/unittest/test/test_skipping.py
+2
-2
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/unittest.rst
View file @
90932848
...
...
@@ -1772,6 +1772,10 @@ Loading and running tests
Return ``True`` if all tests run so far have passed, otherwise returns
``False``.
.. versionchanged:: 3.4
Returns ``False`` if there were any :attr:`unexpectedSuccesses`
from tests marked with the :func:`expectedFailure` decorator.
.. method:: stop()
...
...
Lib/unittest/result.py
View file @
90932848
...
...
@@ -156,11 +156,16 @@ class TestResult(object):
self
.
unexpectedSuccesses
.
append
(
test
)
def
wasSuccessful
(
self
):
"Tells whether or not this result was a success"
return
len
(
self
.
failures
)
==
len
(
self
.
errors
)
==
0
"""Tells whether or not this result was a success."""
# The hasattr check is for test_result's OldResult test. That
# way this method works on objects that lack the attribute.
# (where would such result intances come from? old stored pickles?)
return
((
len
(
self
.
failures
)
==
len
(
self
.
errors
)
==
0
)
and
(
not
hasattr
(
self
,
'unexpectedSuccesses'
)
or
len
(
self
.
unexpectedSuccesses
)
==
0
))
def
stop
(
self
):
"
Indicates that the tests should be aborted
"
"
""Indicates that the tests should be aborted.""
"
self
.
shouldStop
=
True
def
_exc_info_to_string
(
self
,
err
,
test
):
...
...
Lib/unittest/test/test_skipping.py
View file @
90932848
...
...
@@ -158,7 +158,7 @@ class Test_TestSkipping(unittest.TestCase):
[
'startTest'
,
'addUnexpectedSuccess'
,
'stopTest'
])
self
.
assertFalse
(
result
.
failures
)
self
.
assertEqual
(
result
.
unexpectedSuccesses
,
[
test
])
self
.
assert
Tru
e
(
result
.
wasSuccessful
())
self
.
assert
Fals
e
(
result
.
wasSuccessful
())
def
test_unexpected_success_subtests
(
self
):
# Success in all subtests counts as the unexpected success of
...
...
@@ -182,7 +182,7 @@ class Test_TestSkipping(unittest.TestCase):
'addUnexpectedSuccess'
,
'stopTest'
])
self
.
assertFalse
(
result
.
failures
)
self
.
assertEqual
(
result
.
unexpectedSuccesses
,
[
test
])
self
.
assert
Tru
e
(
result
.
wasSuccessful
())
self
.
assert
Fals
e
(
result
.
wasSuccessful
())
def
test_skip_doesnt_run_setup
(
self
):
class
Foo
(
unittest
.
TestCase
):
...
...
Misc/NEWS
View file @
90932848
...
...
@@ -25,6 +25,9 @@ Core and Builtins
Library
-------
- Issue #20165: The unittest module no longer considers tests marked with
@expectedFailure successful if they pass.
- Issue #18574: Added missing newline in 100-Continue reply from
http.server.BaseHTTPRequestHandler. Patch by Nikolaus Rath.
...
...
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