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
Kirill Smelkov
cython
Commits
8cbe1ab9
Commit
8cbe1ab9
authored
Mar 28, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '0.24.x'
parents
a8af26e0
77223135
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
28 deletions
+24
-28
Cython/Debugger/DebugWriter.py
Cython/Debugger/DebugWriter.py
+3
-13
Cython/TestUtils.py
Cython/TestUtils.py
+21
-15
No files found.
Cython/Debugger/DebugWriter.py
View file @
8cbe1ab9
from
__future__
import
with_statemen
t
from
__future__
import
absolute_impor
t
import
os
import
os
import
sys
import
sys
...
@@ -10,24 +10,14 @@ try:
...
@@ -10,24 +10,14 @@ try:
except
ImportError
:
except
ImportError
:
have_lxml
=
False
have_lxml
=
False
try
:
try
:
# Python 2.5
from
xml.etree
import
cElementTree
as
etree
from
xml.etree
import
cElementTree
as
etree
except
ImportError
:
except
ImportError
:
try
:
try
:
# Python 2.5
from
xml.etree
import
ElementTree
as
etree
from
xml.etree
import
ElementTree
as
etree
except
ImportError
:
except
ImportError
:
try
:
etree
=
None
# normal cElementTree install
import
cElementTree
as
etree
except
ImportError
:
try
:
# normal ElementTree install
import
elementtree.ElementTree
as
etree
except
ImportError
:
etree
=
None
from
Cython
.Compiler
import
Errors
from
.
.Compiler
import
Errors
class
CythonDebugWriter
(
object
):
class
CythonDebugWriter
(
object
):
...
...
Cython/TestUtils.py
View file @
8cbe1ab9
import
Cython.Compiler.Errors
as
Errors
from
__future__
import
absolute_import
from
Cython.CodeWriter
import
CodeWriter
from
Cython.Compiler.TreeFragment
import
TreeFragment
,
strip_common_indent
from
Cython.Compiler.Visitor
import
TreeVisitor
,
VisitorTransform
from
Cython.Compiler
import
TreePath
import
os
import
unittest
import
unittest
import
os
,
sys
import
tempfile
import
tempfile
from
.Compiler
import
Errors
from
.CodeWriter
import
CodeWriter
from
.Compiler.TreeFragment
import
TreeFragment
,
strip_common_indent
from
.Compiler.Visitor
import
TreeVisitor
,
VisitorTransform
from
.Compiler
import
TreePath
class
NodeTypeWriter
(
TreeVisitor
):
class
NodeTypeWriter
(
TreeVisitor
):
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -55,12 +57,15 @@ class CythonTest(unittest.TestCase):
...
@@ -55,12 +57,15 @@ class CythonTest(unittest.TestCase):
def
assertLines
(
self
,
expected
,
result
):
def
assertLines
(
self
,
expected
,
result
):
"Checks that the given strings or lists of strings are equal line by line"
"Checks that the given strings or lists of strings are equal line by line"
if
not
isinstance
(
expected
,
list
):
expected
=
expected
.
split
(
u"
\
n
"
)
if
not
isinstance
(
expected
,
list
):
if
not
isinstance
(
result
,
list
):
result
=
result
.
split
(
u"
\
n
"
)
expected
=
expected
.
split
(
u"
\
n
"
)
if
not
isinstance
(
result
,
list
):
result
=
result
.
split
(
u"
\
n
"
)
for
idx
,
(
expected_line
,
result_line
)
in
enumerate
(
zip
(
expected
,
result
)):
for
idx
,
(
expected_line
,
result_line
)
in
enumerate
(
zip
(
expected
,
result
)):
self
.
assertEqual
(
expected_line
,
result_line
,
"Line %d:
\
n
Exp: %s
\
n
Got: %s"
%
(
idx
,
expected_line
,
result_line
))
self
.
assertEqual
(
expected_line
,
result_line
,
"Line %d:
\
n
Exp: %s
\
n
Got: %s"
%
(
idx
,
expected_line
,
result_line
))
self
.
assertEqual
(
len
(
expected
),
len
(
result
),
self
.
assertEqual
(
len
(
expected
),
len
(
result
),
"Unmatched lines. Got:
\
n
%s
\
n
Expected:
\
n
%s"
%
(
"
\
n
"
.
join
(
expected
),
u"
\
n
"
.
join
(
result
)))
"Unmatched lines. Got:
\
n
%s
\
n
Expected:
\
n
%s"
%
(
"
\
n
"
.
join
(
expected
),
u"
\
n
"
.
join
(
result
)))
def
codeToLines
(
self
,
tree
):
def
codeToLines
(
self
,
tree
):
writer
=
CodeWriter
()
writer
=
CodeWriter
()
...
@@ -76,9 +81,10 @@ class CythonTest(unittest.TestCase):
...
@@ -76,9 +81,10 @@ class CythonTest(unittest.TestCase):
expected_lines
=
strip_common_indent
(
expected
.
split
(
"
\
n
"
))
expected_lines
=
strip_common_indent
(
expected
.
split
(
"
\
n
"
))
for
idx
,
(
line
,
expected_line
)
in
enumerate
(
zip
(
result_lines
,
expected_lines
)):
for
idx
,
(
line
,
expected_line
)
in
enumerate
(
zip
(
result_lines
,
expected_lines
)):
self
.
assertEqual
(
expected_line
,
line
,
"Line %d:
\
n
Got: %s
\
n
Exp: %s"
%
(
idx
,
line
,
expected_line
))
self
.
assertEqual
(
expected_line
,
line
,
"Line %d:
\
n
Got: %s
\
n
Exp: %s"
%
(
idx
,
line
,
expected_line
))
self
.
assertEqual
(
len
(
result_lines
),
len
(
expected_lines
),
self
.
assertEqual
(
len
(
result_lines
),
len
(
expected_lines
),
"Unmatched lines. Got:
\
n
%s
\
n
Expected:
\
n
%s"
%
(
"
\
n
"
.
join
(
result_lines
),
expected
))
"Unmatched lines. Got:
\
n
%s
\
n
Expected:
\
n
%s"
%
(
"
\
n
"
.
join
(
result_lines
),
expected
))
def
assertNodeExists
(
self
,
path
,
result_tree
):
def
assertNodeExists
(
self
,
path
,
result_tree
):
self
.
assertNotEqual
(
TreePath
.
find_first
(
result_tree
,
path
),
None
,
self
.
assertNotEqual
(
TreePath
.
find_first
(
result_tree
,
path
),
None
,
...
@@ -107,7 +113,7 @@ class CythonTest(unittest.TestCase):
...
@@ -107,7 +113,7 @@ class CythonTest(unittest.TestCase):
func
()
func
()
self
.
fail
(
"Expected an exception of type %r"
%
exc_type
)
self
.
fail
(
"Expected an exception of type %r"
%
exc_type
)
except
exc_type
as
e
:
except
exc_type
as
e
:
self
.
assert
_
(
isinstance
(
e
,
exc_type
))
self
.
assert
True
(
isinstance
(
e
,
exc_type
))
return
e
return
e
def
should_not_fail
(
self
,
func
):
def
should_not_fail
(
self
,
func
):
...
@@ -116,8 +122,8 @@ class CythonTest(unittest.TestCase):
...
@@ -116,8 +122,8 @@ class CythonTest(unittest.TestCase):
the return value of func."""
the return value of func."""
try
:
try
:
return
func
()
return
func
()
except
:
except
Exception
as
exc
:
self
.
fail
(
str
(
sys
.
exc_info
()[
1
]
))
self
.
fail
(
str
(
exc
))
class
TransformTest
(
CythonTest
):
class
TransformTest
(
CythonTest
):
...
...
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