Commit 8cbe1ab9 authored by Stefan Behnel's avatar Stefan Behnel

Merge branch '0.24.x'

parents a8af26e0 77223135
from __future__ import with_statement
from __future__ import absolute_import
import os
import sys
......@@ -10,24 +10,14 @@ try:
except ImportError:
have_lxml = False
try:
# Python 2.5
from xml.etree import cElementTree as etree
except ImportError:
try:
# Python 2.5
from xml.etree import ElementTree as etree
except ImportError:
try:
# 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):
......
import Cython.Compiler.Errors as Errors
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
from __future__ import absolute_import
import os
import unittest
import os, sys
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):
def __init__(self):
......@@ -55,10 +57,13 @@ class CythonTest(unittest.TestCase):
def assertLines(self, expected, result):
"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(result, list): result = result.split(u"\n")
if not isinstance(expected, list):
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)):
self.assertEqual(expected_line, result_line, "Line %d:\nExp: %s\nGot: %s" % (idx, expected_line, result_line))
self.assertEqual(expected_line, result_line,
"Line %d:\nExp: %s\nGot: %s" % (idx, expected_line, result_line))
self.assertEqual(len(expected), len(result),
"Unmatched lines. Got:\n%s\nExpected:\n%s" % ("\n".join(expected), u"\n".join(result)))
......@@ -76,7 +81,8 @@ class CythonTest(unittest.TestCase):
expected_lines = strip_common_indent(expected.split("\n"))
for idx, (line, expected_line) in enumerate(zip(result_lines, expected_lines)):
self.assertEqual(expected_line, line, "Line %d:\nGot: %s\nExp: %s" % (idx, line, expected_line))
self.assertEqual(expected_line, line,
"Line %d:\nGot: %s\nExp: %s" % (idx, line, expected_line))
self.assertEqual(len(result_lines), len(expected_lines),
"Unmatched lines. Got:\n%s\nExpected:\n%s" % ("\n".join(result_lines), expected))
......@@ -107,7 +113,7 @@ class CythonTest(unittest.TestCase):
func()
self.fail("Expected an exception of type %r" % exc_type)
except exc_type as e:
self.assert_(isinstance(e, exc_type))
self.assertTrue(isinstance(e, exc_type))
return e
def should_not_fail(self, func):
......@@ -116,8 +122,8 @@ class CythonTest(unittest.TestCase):
the return value of func."""
try:
return func()
except:
self.fail(str(sys.exc_info()[1]))
except Exception as exc:
self.fail(str(exc))
class TransformTest(CythonTest):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment