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
9f9d80b6
Commit
9f9d80b6
authored
Mar 31, 2011
by
Haoyu Bai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more test for raise ... from ...
parent
6ca2de34
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
tests/run/test_raisefrom.pyx
tests/run/test_raisefrom.pyx
+39
-0
No files found.
tests/run/test_raisefrom.pyx
0 → 100644
View file @
9f9d80b6
import
unittest
# adapted from pyregr
class
TestCause
(
unittest
.
TestCase
):
def
test_invalid_cause
(
self
):
try
:
raise
IndexError
from
5
except
TypeError
as
e
:
self
.
assertIn
(
"exception cause"
,
str
(
e
))
else
:
self
.
fail
(
"No exception raised"
)
def
test_class_cause
(
self
):
try
:
raise
IndexError
from
KeyError
except
IndexError
as
e
:
self
.
assertIsInstance
(
e
.
__cause__
,
KeyError
)
else
:
self
.
fail
(
"No exception raised"
)
def
test_instance_cause
(
self
):
cause
=
KeyError
()
try
:
raise
IndexError
from
cause
except
IndexError
as
e
:
self
.
assertTrue
(
e
.
__cause__
is
cause
)
else
:
self
.
fail
(
"No exception raised"
)
def
test_erroneous_cause
(
self
):
class
MyException
(
Exception
):
def
__init__
(
self
):
raise
RuntimeError
()
try
:
raise
IndexError
from
MyException
except
RuntimeError
:
pass
else
:
self
.
fail
(
"No exception raised"
)
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