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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
e1901d13
Commit
e1901d13
authored
Aug 13, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
many more test fixes for Py2.6
parent
20e6808b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
4 deletions
+56
-4
tests/run/test_grammar.py
tests/run/test_grammar.py
+56
-4
No files found.
tests/run/test_grammar.py
View file @
e1901d13
### COPIED FROM CPython 3.5 - ADDED PART FOLLOWS ###
# cython: language_level=3
import
contextlib
from
tempfile
import
NamedTemporaryFile
from
Cython.Compiler.Main
import
compile
as
cython_compile
...
...
@@ -35,7 +37,29 @@ def compile(code, name, what):
raise
SyntaxError
(
'unexpected EOF'
)
# see usage of compile() below
### END OF CYTHON ADDED PART ###
def
exec
(
code
):
result
=
_compile
(
code
)
if
not
result
.
c_file
:
raise
SyntaxError
(
'unexpected EOF'
)
# see usage of compile() below
import
unittest
if
not
hasattr
(
unittest
,
'skipUnless'
):
def
skipUnless
(
condition
,
message
):
def
decorator
(
func
):
if
condition
:
return
func
def
test_method
(
self
):
print
(
message
)
return
test_method
return
decorator
unittest
.
skipUnless
=
skipUnless
### END OF CYTHON ADDED PART - COPIED PART FOLLOWS ###
# Python test set -- part 1, grammar.
# This just tests whether the parser accepts them all.
...
...
@@ -1204,22 +1228,50 @@ class GrammarTests(unittest.TestCase):
GrammarTests
.
assertRaisesRegex
=
lambda
self
,
exc
,
msg
:
self
.
assertRaises
(
exc
)
if
sys
.
version_info
<
(
2
,
7
):
def
assertRaises
(
self
,
exc_type
,
func
=
None
,
*
args
,
**
kwargs
):
if
func
is
not
None
:
return
unittest
.
TestCase
.
assertRaises
(
self
,
exc_type
,
func
,
*
args
,
**
kwargs
)
@
contextlib
.
contextmanager
def
assertRaisesCM
():
class
Result
(
object
):
exception
=
exc_type
(
"unexpected EOF"
)
# see usage above
try
:
yield
Result
()
except
exc_type
:
self
.
assertTrue
(
True
)
else
:
self
.
assertTrue
(
False
)
return
assertRaisesCM
()
GrammarTests
.
assertRaises
=
assertRaises
TokenTests
.
assertRaises
=
assertRaises
if
not
hasattr
(
unittest
.
TestCase
,
'subTest'
):
import
contextlib
@
contextlib
.
contextmanager
def
subTest
(
self
,
cod
e
,
**
kwargs
):
def
subTest
(
self
,
sourc
e
,
**
kwargs
):
try
:
yield
except
Exception
:
print
(
cod
e
)
print
(
sourc
e
)
raise
GrammarTests
.
subTest
=
subTest
if
not
hasattr
(
unittest
.
TestCase
,
'assertIn'
):
def
assertIn
(
self
,
member
,
container
,
msg
=
None
):
self
.
assertTrue
(
member
in
container
,
msg
)
TokenTests
.
assertIn
=
assertIn
# FIXME: disabling some tests for real Cython bugs here
del
GrammarTests
.
test_comprehension_specials
# iterable pre-calculation in generator expression
del
GrammarTests
.
test_funcdef
# annotation mangling
# this test is difficult to enable in Py2.6
if
sys
.
version_info
<
(
2
,
7
):
del
GrammarTests
.
test_former_statements_refer_to_builtins
if
__name__
==
'__main__'
:
unittest
.
main
()
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