Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
8b342daf
Commit
8b342daf
authored
Feb 12, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for 'raise ... from None'
parent
464f389c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
tests/run/test_raisefrom.pyx
tests/run/test_raisefrom.pyx
+27
-0
No files found.
tests/run/test_raisefrom.pyx
View file @
8b342daf
import
sys
import
unittest
# adapted from pyregr
class
TestCause
(
unittest
.
TestCase
):
def
test_invalid_cause
(
self
):
...
...
@@ -9,6 +12,30 @@ class TestCause(unittest.TestCase):
else
:
self
.
fail
(
"No exception raised"
)
def
test_raise_from_none_sets_no_cause
(
self
):
try
:
raise
IndexError
from
None
except
IndexError
as
e
:
self
.
assertFalse
(
e
.
__cause__
)
if
sys
.
version_info
[:
2
]
>=
(
3
,
3
):
self
.
assertTrue
(
e
.
__suppress_context__
)
else
:
self
.
fail
(
"No exception raised"
)
def
test_raise_from_none_covers_context
(
self
):
try
:
try
:
raise
IndexError
(
"INDEX"
)
except
IndexError
as
e
:
raise
ValueError
(
"VALUE"
)
from
None
else
:
self
.
fail
(
"No exception raised"
)
except
ValueError
as
e
:
self
.
assertFalse
(
e
.
__cause__
)
self
.
assertTrue
(
e
.
__context__
)
if
sys
.
version_info
[:
2
]
>=
(
3
,
3
):
self
.
assertTrue
(
e
.
__suppress_context__
)
def
test_class_cause
(
self
):
try
:
raise
IndexError
from
KeyError
...
...
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