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
ce1a9f30
Commit
ce1a9f30
authored
Jun 20, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added more tests for issue #27122.
parent
5943ea76
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
Lib/test/test_contextlib.py
Lib/test/test_contextlib.py
+11
-5
No files found.
Lib/test/test_contextlib.py
View file @
ce1a9f30
...
...
@@ -763,8 +763,9 @@ class TestExitStack(unittest.TestCase):
self
.
assertIs
(
stack
.
_exit_callbacks
[
-
1
],
cm
)
def
test_dont_reraise_RuntimeError
(
self
):
"""https://bugs.python.org/issue27122"""
# https://bugs.python.org/issue27122
class
UniqueException
(
Exception
):
pass
class
UniqueRuntimeError
(
RuntimeError
):
pass
@
contextmanager
def
second
():
...
...
@@ -780,15 +781,20 @@ class TestExitStack(unittest.TestCase):
except
Exception
as
exc
:
raise
exc
# The RuntimeError should be caught by second()'s exception
# The
Unique
RuntimeError should be caught by second()'s exception
# handler which chain raised a new UniqueException.
with
self
.
assertRaises
(
UniqueException
)
as
err_ctx
:
with
ExitStack
()
as
es_ctx
:
es_ctx
.
enter_context
(
second
())
es_ctx
.
enter_context
(
first
())
raise
RuntimeError
(
"please no infinite loop."
)
self
.
assertEqual
(
err_ctx
.
exception
.
args
[
0
],
"new exception"
)
raise
UniqueRuntimeError
(
"please no infinite loop."
)
exc
=
err_ctx
.
exception
self
.
assertIsInstance
(
exc
,
UniqueException
)
self
.
assertIsInstance
(
exc
.
__context__
,
UniqueRuntimeError
)
self
.
assertIsNone
(
exc
.
__context__
.
__context__
)
self
.
assertIsNone
(
exc
.
__context__
.
__cause__
)
self
.
assertIs
(
exc
.
__cause__
,
exc
.
__context__
)
class
TestRedirectStream
:
...
...
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