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
049060c2
Commit
049060c2
authored
May 16, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverted issue #24134 changes.
parent
d39d962c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
12 deletions
+7
-12
Lib/unittest/case.py
Lib/unittest/case.py
+5
-7
Lib/unittest/test/test_case.py
Lib/unittest/test/test_case.py
+0
-5
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/unittest/case.py
View file @
049060c2
...
@@ -127,8 +127,6 @@ class _AssertRaisesContext(object):
...
@@ -127,8 +127,6 @@ class _AssertRaisesContext(object):
(
expected_regexp
.
pattern
,
str
(
exc_value
)))
(
expected_regexp
.
pattern
,
str
(
exc_value
)))
return
True
return
True
def
_sentinel
(
*
args
,
**
kwargs
):
raise
AssertionError
(
'Should never be called'
)
class
TestCase
(
object
):
class
TestCase
(
object
):
"""A class whose instances are single test cases.
"""A class whose instances are single test cases.
...
@@ -445,7 +443,7 @@ class TestCase(object):
...
@@ -445,7 +443,7 @@ class TestCase(object):
return
'%s : %s'
%
(
safe_repr
(
standardMsg
),
safe_repr
(
msg
))
return
'%s : %s'
%
(
safe_repr
(
standardMsg
),
safe_repr
(
msg
))
def
assertRaises
(
self
,
excClass
,
callableObj
=
_sentinel
,
*
args
,
**
kwargs
):
def
assertRaises
(
self
,
excClass
,
callableObj
=
None
,
*
args
,
**
kwargs
):
"""Fail unless an exception of class excClass is raised
"""Fail unless an exception of class excClass is raised
by callableObj when invoked with arguments args and keyword
by callableObj when invoked with arguments args and keyword
arguments kwargs. If a different type of exception is
arguments kwargs. If a different type of exception is
...
@@ -453,7 +451,7 @@ class TestCase(object):
...
@@ -453,7 +451,7 @@ class TestCase(object):
deemed to have suffered an error, exactly as for an
deemed to have suffered an error, exactly as for an
unexpected exception.
unexpected exception.
If called with callableObj omitted, will return a
If called with callableObj omitted
or None
, will return a
context object used like this::
context object used like this::
with self.assertRaises(SomeException):
with self.assertRaises(SomeException):
...
@@ -469,7 +467,7 @@ class TestCase(object):
...
@@ -469,7 +467,7 @@ class TestCase(object):
self.assertEqual(the_exception.error_code, 3)
self.assertEqual(the_exception.error_code, 3)
"""
"""
context
=
_AssertRaisesContext
(
excClass
,
self
)
context
=
_AssertRaisesContext
(
excClass
,
self
)
if
callableObj
is
_sentinel
:
if
callableObj
is
None
:
return
context
return
context
with
context
:
with
context
:
callableObj
(
*
args
,
**
kwargs
)
callableObj
(
*
args
,
**
kwargs
)
...
@@ -975,7 +973,7 @@ class TestCase(object):
...
@@ -975,7 +973,7 @@ class TestCase(object):
self
.
fail
(
self
.
_formatMessage
(
msg
,
standardMsg
))
self
.
fail
(
self
.
_formatMessage
(
msg
,
standardMsg
))
def
assertRaisesRegexp
(
self
,
expected_exception
,
expected_regexp
,
def
assertRaisesRegexp
(
self
,
expected_exception
,
expected_regexp
,
callable_obj
=
_sentinel
,
*
args
,
**
kwargs
):
callable_obj
=
None
,
*
args
,
**
kwargs
):
"""Asserts that the message in a raised exception matches a regexp.
"""Asserts that the message in a raised exception matches a regexp.
Args:
Args:
...
@@ -989,7 +987,7 @@ class TestCase(object):
...
@@ -989,7 +987,7 @@ class TestCase(object):
if
expected_regexp
is
not
None
:
if
expected_regexp
is
not
None
:
expected_regexp
=
re
.
compile
(
expected_regexp
)
expected_regexp
=
re
.
compile
(
expected_regexp
)
context
=
_AssertRaisesContext
(
expected_exception
,
self
,
expected_regexp
)
context
=
_AssertRaisesContext
(
expected_exception
,
self
,
expected_regexp
)
if
callable_obj
is
_sentinel
:
if
callable_obj
is
None
:
return
context
return
context
with
context
:
with
context
:
callable_obj
(
*
args
,
**
kwargs
)
callable_obj
(
*
args
,
**
kwargs
)
...
...
Lib/unittest/test/test_case.py
View file @
049060c2
...
@@ -967,9 +967,6 @@ test case
...
@@ -967,9 +967,6 @@ test case
# Failure when no exception is raised
# Failure when no exception is raised
with
self
.
assertRaises
(
self
.
failureException
):
with
self
.
assertRaises
(
self
.
failureException
):
self
.
assertRaises
(
ExceptionMock
,
lambda
:
0
)
self
.
assertRaises
(
ExceptionMock
,
lambda
:
0
)
# Failure when the function is None
with
self
.
assertRaises
(
TypeError
):
self
.
assertRaises
(
ExceptionMock
,
None
)
# Failure when another exception is raised
# Failure when another exception is raised
with
self
.
assertRaises
(
ExceptionMock
):
with
self
.
assertRaises
(
ExceptionMock
):
self
.
assertRaises
(
ValueError
,
Stub
)
self
.
assertRaises
(
ValueError
,
Stub
)
...
@@ -1008,8 +1005,6 @@ test case
...
@@ -1008,8 +1005,6 @@ test case
self
.
assertRaisesRegexp
(
ExceptionMock
,
re
.
compile
(
'expect$'
),
Stub
)
self
.
assertRaisesRegexp
(
ExceptionMock
,
re
.
compile
(
'expect$'
),
Stub
)
self
.
assertRaisesRegexp
(
ExceptionMock
,
'expect$'
,
Stub
)
self
.
assertRaisesRegexp
(
ExceptionMock
,
'expect$'
,
Stub
)
self
.
assertRaisesRegexp
(
ExceptionMock
,
u'expect$'
,
Stub
)
self
.
assertRaisesRegexp
(
ExceptionMock
,
u'expect$'
,
Stub
)
with
self
.
assertRaises
(
TypeError
):
self
.
assertRaisesRegexp
(
ExceptionMock
,
'expect$'
,
None
)
def
testAssertNotRaisesRegexp
(
self
):
def
testAssertNotRaisesRegexp
(
self
):
self
.
assertRaisesRegexp
(
self
.
assertRaisesRegexp
(
...
...
Misc/NEWS
View file @
049060c2
...
@@ -13,6 +13,8 @@ Core and Builtins
...
@@ -13,6 +13,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #24134: Reverted issue #24134 changes.
What'
s
New
in
Python
2.7.10
release
candidate
1
?
What'
s
New
in
Python
2.7.10
release
candidate
1
?
================================================
================================================
...
...
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