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
8a968fe5
Commit
8a968fe5
authored
Sep 15, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable some CPython exception unit tests in older Python versions.
parent
f10d8cba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
runtests.py
runtests.py
+2
-0
tests/run/test_exceptions.pyx
tests/run/test_exceptions.pyx
+18
-9
No files found.
runtests.py
View file @
8a968fe5
...
@@ -145,6 +145,7 @@ EXT_DEP_MODULES = {
...
@@ -145,6 +145,7 @@ EXT_DEP_MODULES = {
'Coverage'
:
'Cython.Coverage'
,
'Coverage'
:
'Cython.Coverage'
,
'tag:ipython'
:
'IPython.testing.globalipapp'
,
'tag:ipython'
:
'IPython.testing.globalipapp'
,
'tag:jedi'
:
'jedi_BROKEN_AND_DISABLED'
,
'tag:jedi'
:
'jedi_BROKEN_AND_DISABLED'
,
'tag:test.support'
:
'test.support'
,
# support module for CPython unit tests
}
}
def
patch_inspect_isfunction
():
def
patch_inspect_isfunction
():
...
@@ -433,6 +434,7 @@ VER_DEP_MODULES = {
...
@@ -433,6 +434,7 @@ VER_DEP_MODULES = {
'run.py35_asyncio_async_def',
'run.py35_asyncio_async_def',
'run.mod__spec__',
'run.mod__spec__',
'run.pep526_variable_annotations', # typing module
'run.pep526_variable_annotations', # typing module
'run.test_exceptions', # copied from Py3.7+
]),
]),
}
}
...
...
tests/run/test_exceptions.pyx
View file @
8a968fe5
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
# cython: language_level=3
# cython: language_level=3
# mode: run
# mode: run
# tag: generator, exception, tryfinally, tryexcept
# tag: generator, exception, tryfinally, tryexcept
, test.support
import
copy
import
copy
import
os
import
os
...
@@ -14,8 +14,9 @@ import weakref
...
@@ -14,8 +14,9 @@ import weakref
import
errno
import
errno
from
test.support
import
(
TESTFN
,
captured_stderr
,
check_impl_detail
,
from
test.support
import
(
TESTFN
,
captured_stderr
,
check_impl_detail
,
check_warnings
,
cpython_only
,
gc_collect
,
run_unittest
,
check_warnings
,
gc_collect
,
no_tracing
,
unlink
,
import_module
,
script_helper
,
# no_tracing, cpython_only,
unlink
,
import_module
,
script_helper
,
SuppressCrashReport
)
SuppressCrashReport
)
no_tracing
=
unittest
.
skip
(
"For nested functions, Cython generates a C call without recursion checks."
)
no_tracing
=
unittest
.
skip
(
"For nested functions, Cython generates a C call without recursion checks."
)
...
@@ -163,7 +164,7 @@ class ExceptionTests(unittest.TestCase):
...
@@ -163,7 +164,7 @@ class ExceptionTests(unittest.TestCase):
try
:
try
:
compile
(
src
,
'<fragment>'
,
'exec'
)
compile
(
src
,
'<fragment>'
,
'exec'
)
except
exception
as
e
:
except
exception
as
e
:
if
e
.
msg
!=
msg
:
if
e
.
msg
!=
msg
and
sys
.
version_info
>=
(
3
,
6
)
:
self
.
fail
(
"expected %s, got %s"
%
(
msg
,
e
.
msg
))
self
.
fail
(
"expected %s, got %s"
%
(
msg
,
e
.
msg
))
else
:
else
:
self
.
fail
(
"failed to get expected SyntaxError"
)
self
.
fail
(
"failed to get expected SyntaxError"
)
...
@@ -1174,11 +1175,13 @@ class ExceptionTests(unittest.TestCase):
...
@@ -1174,11 +1175,13 @@ class ExceptionTests(unittest.TestCase):
self
.
assertIn
(
"raise exc"
,
report
)
self
.
assertIn
(
"raise exc"
,
report
)
if
test_class
is
BrokenExceptionDel
:
if
test_class
is
BrokenExceptionDel
:
self
.
assertIn
(
"BrokenStrException"
,
report
)
self
.
assertIn
(
"BrokenStrException"
,
report
)
self
.
assertIn
(
"<exception str() failed>"
,
report
)
if
sys
.
version_info
>=
(
3
,
6
):
self
.
assertIn
(
"<exception str() failed>"
,
report
)
else
:
else
:
self
.
assertIn
(
"ValueError"
,
report
)
self
.
assertIn
(
"ValueError"
,
report
)
self
.
assertIn
(
"del is broken"
,
report
)
self
.
assertIn
(
"del is broken"
,
report
)
self
.
assertTrue
(
report
.
endswith
(
"
\
n
"
))
if
sys
.
version_info
>=
(
3
,
6
):
self
.
assertTrue
(
report
.
endswith
(
"
\
n
"
))
def
test_unhandled
(
self
):
def
test_unhandled
(
self
):
# Check for sensible reporting of unhandled exceptions
# Check for sensible reporting of unhandled exceptions
...
@@ -1196,10 +1199,12 @@ class ExceptionTests(unittest.TestCase):
...
@@ -1196,10 +1199,12 @@ class ExceptionTests(unittest.TestCase):
self
.
assertIn
(
"raise exc"
,
report
)
self
.
assertIn
(
"raise exc"
,
report
)
self
.
assertIn
(
exc_type
.
__name__
,
report
)
self
.
assertIn
(
exc_type
.
__name__
,
report
)
if
exc_type
is
BrokenStrException
:
if
exc_type
is
BrokenStrException
:
self
.
assertIn
(
"<exception str() failed>"
,
report
)
if
sys
.
version_info
>=
(
3
,
6
):
self
.
assertIn
(
"<exception str() failed>"
,
report
)
else
:
else
:
self
.
assertIn
(
"test message"
,
report
)
self
.
assertIn
(
"test message"
,
report
)
self
.
assertTrue
(
report
.
endswith
(
"
\
n
"
))
if
sys
.
version_info
>=
(
3
,
6
):
self
.
assertTrue
(
report
.
endswith
(
"
\
n
"
))
@
cpython_only
@
cpython_only
def
test_memory_error_in_PyErr_PrintEx
(
self
):
def
test_memory_error_in_PyErr_PrintEx
(
self
):
...
@@ -1279,6 +1284,7 @@ class ExceptionTests(unittest.TestCase):
...
@@ -1279,6 +1284,7 @@ class ExceptionTests(unittest.TestCase):
class
ImportErrorTests
(
unittest
.
TestCase
):
class
ImportErrorTests
(
unittest
.
TestCase
):
@
unittest
.
skipIf
(
sys
.
version_info
<
(
3
,
6
),
"Requires Py3.6+"
)
def
test_attributes
(
self
):
def
test_attributes
(
self
):
# Setting 'name' and 'path' should not be a problem.
# Setting 'name' and 'path' should not be a problem.
exc
=
ImportError
(
'test'
)
exc
=
ImportError
(
'test'
)
...
@@ -1297,7 +1303,8 @@ class ImportErrorTests(unittest.TestCase):
...
@@ -1297,7 +1303,8 @@ class ImportErrorTests(unittest.TestCase):
self
.
assertEqual
(
exc
.
name
,
'somename'
)
self
.
assertEqual
(
exc
.
name
,
'somename'
)
self
.
assertEqual
(
exc
.
path
,
'somepath'
)
self
.
assertEqual
(
exc
.
path
,
'somepath'
)
msg
=
"'invalid' is an invalid keyword argument for ImportError"
msg
=
(
"'invalid' is an invalid keyword argument for ImportError"
if
sys
.
version_info
>=
(
3
,
7
)
else
".*keyword argument.*"
)
with
self
.
assertRaisesRegex
(
TypeError
,
msg
):
with
self
.
assertRaisesRegex
(
TypeError
,
msg
):
ImportError
(
'test'
,
invalid
=
'keyword'
)
ImportError
(
'test'
,
invalid
=
'keyword'
)
...
@@ -1313,6 +1320,7 @@ class ImportErrorTests(unittest.TestCase):
...
@@ -1313,6 +1320,7 @@ class ImportErrorTests(unittest.TestCase):
with
self
.
assertRaisesRegex
(
TypeError
,
msg
):
with
self
.
assertRaisesRegex
(
TypeError
,
msg
):
ImportError
(
'test'
,
invalid
=
'keyword'
,
another
=
True
)
ImportError
(
'test'
,
invalid
=
'keyword'
,
another
=
True
)
@
unittest
.
skipIf
(
sys
.
version_info
<
(
3
,
7
),
"requires Py3.7+"
)
def
test_reset_attributes
(
self
):
def
test_reset_attributes
(
self
):
exc
=
ImportError
(
'test'
,
name
=
'name'
,
path
=
'path'
)
exc
=
ImportError
(
'test'
,
name
=
'name'
,
path
=
'path'
)
self
.
assertEqual
(
exc
.
args
,
(
'test'
,))
self
.
assertEqual
(
exc
.
args
,
(
'test'
,))
...
@@ -1334,6 +1342,7 @@ class ImportErrorTests(unittest.TestCase):
...
@@ -1334,6 +1342,7 @@ class ImportErrorTests(unittest.TestCase):
exc
=
ImportError
(
arg
)
exc
=
ImportError
(
arg
)
self
.
assertEqual
(
str
(
arg
),
str
(
exc
))
self
.
assertEqual
(
str
(
arg
),
str
(
exc
))
@
unittest
.
skipIf
(
sys
.
version_info
<
(
3
,
6
),
"Requires Py3.6+"
)
def
test_copy_pickle
(
self
):
def
test_copy_pickle
(
self
):
for
kwargs
in
(
dict
(),
for
kwargs
in
(
dict
(),
dict
(
name
=
'somename'
),
dict
(
name
=
'somename'
),
...
...
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