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
ed599b7c
Commit
ed599b7c
authored
Aug 28, 2015
by
Robert Collins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #21112: Fix regression in unittest.expectedFailure on subclasses.
Patch from Berker Peksag.
parent
5e580da0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
2 deletions
+41
-2
Lib/unittest/case.py
Lib/unittest/case.py
+5
-2
Lib/unittest/test/test_skipping.py
Lib/unittest/test/test_skipping.py
+33
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/unittest/case.py
View file @
ed599b7c
...
...
@@ -563,8 +563,11 @@ class TestCase(object):
finally
:
result
.
stopTest
(
self
)
return
expecting_failure
=
getattr
(
testMethod
,
"__unittest_expecting_failure__"
,
False
)
expecting_failure_method
=
getattr
(
testMethod
,
"__unittest_expecting_failure__"
,
False
)
expecting_failure_class
=
getattr
(
self
,
"__unittest_expecting_failure__"
,
False
)
expecting_failure
=
expecting_failure_class
or
expecting_failure_method
outcome
=
_Outcome
(
result
)
try
:
self
.
_outcome
=
outcome
...
...
Lib/unittest/test/test_skipping.py
View file @
ed599b7c
...
...
@@ -120,6 +120,39 @@ class Test_TestSkipping(unittest.TestCase):
self
.
assertEqual
(
result
.
expectedFailures
[
0
][
0
],
test
)
self
.
assertTrue
(
result
.
wasSuccessful
())
def
test_expected_failure_with_wrapped_class
(
self
):
@
unittest
.
expectedFailure
class
Foo
(
unittest
.
TestCase
):
def
test_1
(
self
):
self
.
assertTrue
(
False
)
events
=
[]
result
=
LoggingResult
(
events
)
test
=
Foo
(
"test_1"
)
test
.
run
(
result
)
self
.
assertEqual
(
events
,
[
'startTest'
,
'addExpectedFailure'
,
'stopTest'
])
self
.
assertEqual
(
result
.
expectedFailures
[
0
][
0
],
test
)
self
.
assertTrue
(
result
.
wasSuccessful
())
def
test_expected_failure_with_wrapped_subclass
(
self
):
class
Foo
(
unittest
.
TestCase
):
def
test_1
(
self
):
self
.
assertTrue
(
False
)
@
unittest
.
expectedFailure
class
Bar
(
Foo
):
pass
events
=
[]
result
=
LoggingResult
(
events
)
test
=
Bar
(
"test_1"
)
test
.
run
(
result
)
self
.
assertEqual
(
events
,
[
'startTest'
,
'addExpectedFailure'
,
'stopTest'
])
self
.
assertEqual
(
result
.
expectedFailures
[
0
][
0
],
test
)
self
.
assertTrue
(
result
.
wasSuccessful
())
def
test_expected_failure_subtests
(
self
):
# A failure in any subtest counts as the expected failure of the
# whole test.
...
...
Misc/NEWS
View file @
ed599b7c
...
...
@@ -75,6 +75,9 @@ Core and Builtins
Library
-------
-
Issue
#
21112
:
Fix
regression
in
unittest
.
expectedFailure
on
subclasses
.
Patch
from
Berker
Peksag
.
-
Issue
#
24764
:
cgi
.
FieldStorage
.
read_multi
()
now
ignores
the
Content
-
Length
header
in
part
headers
.
Patch
written
by
Peter
Landry
and
reviewed
by
Pierre
Quentel
.
...
...
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