From 93750dc88e67b947a143b00fb479c03da539d7f5 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 27 Oct 2009 21:57:28 +0100 Subject: [PATCH] test fixes for Py2.4 --- tests/run/cdivision_CEP_516.pyx | 12 ++++++++++++ tests/run/funcexceptreturn.pyx | 2 +- tests/run/index.pyx | 3 ++- tests/run/profile_test.pyx | 7 +++++++ tests/run/str_encoding_latin1.pyx | 3 +-- tests/run/tuple.pyx | 6 ++++++ tests/run/withstat.pyx | 5 +++++ 7 files changed, 34 insertions(+), 4 deletions(-) diff --git a/tests/run/cdivision_CEP_516.pyx b/tests/run/cdivision_CEP_516.pyx index adc3cd9d..1a94ef29 100644 --- a/tests/run/cdivision_CEP_516.pyx +++ b/tests/run/cdivision_CEP_516.pyx @@ -76,6 +76,18 @@ Traceback (most recent call last): OverflowError: value too large to perform division """ +def _all(seq): + for x in seq: + if not x: + return False + return True + +try: + all +except NameError: + all = _all + + cimport cython @cython.cdivision(False) diff --git a/tests/run/funcexceptreturn.pyx b/tests/run/funcexceptreturn.pyx index 358ee3d7..761948d4 100644 --- a/tests/run/funcexceptreturn.pyx +++ b/tests/run/funcexceptreturn.pyx @@ -5,7 +5,7 @@ __doc__ = u""" >>> print(sys.exc_info()[0]) # 0 None >>> exc = test_c() ->>> type(exc) is TestException +>>> isinstance(exc, TestException) or exc True >>> print(sys.exc_info()[0]) # test_c() None diff --git a/tests/run/index.pyx b/tests/run/index.pyx index 305505ca..e3cf963c 100644 --- a/tests/run/index.pyx +++ b/tests/run/index.pyx @@ -51,7 +51,8 @@ TypeError: 'int' object is unsubscriptable import sys if sys.version_info[0] >= 3: __doc__ = __doc__.replace(u'is unsubscriptable', u'is not subscriptable') - +elif sys.version_info < (2,5): + __doc__ = __doc__.replace(u"'int' object is unsubscriptable", u'unsubscriptable object') def index_tuple(tuple t, int i): return t[i] diff --git a/tests/run/profile_test.pyx b/tests/run/profile_test.pyx index f231b3e7..f2537cfe 100644 --- a/tests/run/profile_test.pyx +++ b/tests/run/profile_test.pyx @@ -23,6 +23,13 @@ __doc__ = u""" >>> os.unlink(statsfile) """ +import sys +if sys.version_info < (2,5): + # disable in earlier versions + __doc__ = """ +>>> # nothing to test here ... +""" + cimport cython def test_profile(long N): diff --git a/tests/run/str_encoding_latin1.pyx b/tests/run/str_encoding_latin1.pyx index 93f99c07..0ac785d1 100644 --- a/tests/run/str_encoding_latin1.pyx +++ b/tests/run/str_encoding_latin1.pyx @@ -36,8 +36,7 @@ True """ # recoding/escaping is required to properly pass the literals to doctest -).encode('unicode_escape').decode('ASCII') - +).encode('unicode_escape').decode('ASCII').replace(u'\\n', u'\n') a = 'abc' s = 'aäÄÖöo' diff --git a/tests/run/tuple.pyx b/tests/run/tuple.pyx index 869107a2..b7c5e051 100644 --- a/tests/run/tuple.pyx +++ b/tests/run/tuple.pyx @@ -19,6 +19,12 @@ __doc__ = u""" TypeError: 'NoneType' object is not iterable """ +import sys +if sys.version_info < (2,5): + __doc__ = __doc__.replace( + u"'NoneType' object is not iterable\n >>> tuple_none_list()", + u'iteration over non-sequence\n >>> tuple_none_list()') + def f(obj1, obj2, obj3, obj4, obj5): obj1 = () return obj1 diff --git a/tests/run/withstat.pyx b/tests/run/withstat.pyx index 6f43ea8b..e31e7db8 100644 --- a/tests/run/withstat.pyx +++ b/tests/run/withstat.pyx @@ -38,6 +38,11 @@ enter exit """ +import sys +if sys.version_info < (2,5): + __doc__ = __doc__.replace(u"exit ", + u"exit ") + def typename(t): return u"" % type(t).__name__ -- 2.26.2