Commit 93750dc8 authored by Stefan Behnel's avatar Stefan Behnel

test fixes for Py2.4

parent 0ac24ec1
...@@ -76,6 +76,18 @@ Traceback (most recent call last): ...@@ -76,6 +76,18 @@ Traceback (most recent call last):
OverflowError: value too large to perform division 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 cimport cython
@cython.cdivision(False) @cython.cdivision(False)
......
...@@ -5,7 +5,7 @@ __doc__ = u""" ...@@ -5,7 +5,7 @@ __doc__ = u"""
>>> print(sys.exc_info()[0]) # 0 >>> print(sys.exc_info()[0]) # 0
None None
>>> exc = test_c() >>> exc = test_c()
>>> type(exc) is TestException >>> isinstance(exc, TestException) or exc
True True
>>> print(sys.exc_info()[0]) # test_c() >>> print(sys.exc_info()[0]) # test_c()
None None
......
...@@ -51,7 +51,8 @@ TypeError: 'int' object is unsubscriptable ...@@ -51,7 +51,8 @@ TypeError: 'int' object is unsubscriptable
import sys import sys
if sys.version_info[0] >= 3: if sys.version_info[0] >= 3:
__doc__ = __doc__.replace(u'is unsubscriptable', u'is not subscriptable') __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): def index_tuple(tuple t, int i):
return t[i] return t[i]
......
...@@ -23,6 +23,13 @@ __doc__ = u""" ...@@ -23,6 +23,13 @@ __doc__ = u"""
>>> os.unlink(statsfile) >>> os.unlink(statsfile)
""" """
import sys
if sys.version_info < (2,5):
# disable in earlier versions
__doc__ = """
>>> # nothing to test here ...
"""
cimport cython cimport cython
def test_profile(long N): def test_profile(long N):
......
...@@ -36,8 +36,7 @@ True ...@@ -36,8 +36,7 @@ True
""" """
# recoding/escaping is required to properly pass the literals to doctest # 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' a = 'abc'
s = 'ao' s = 'ao'
......
...@@ -19,6 +19,12 @@ __doc__ = u""" ...@@ -19,6 +19,12 @@ __doc__ = u"""
TypeError: 'NoneType' object is not iterable 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): def f(obj1, obj2, obj3, obj4, obj5):
obj1 = () obj1 = ()
return obj1 return obj1
......
...@@ -38,6 +38,11 @@ enter ...@@ -38,6 +38,11 @@ enter
exit <type 'NoneType'> <type 'NoneType'> <type 'NoneType'> exit <type 'NoneType'> <type 'NoneType'> <type 'NoneType'>
""" """
import sys
if sys.version_info < (2,5):
__doc__ = __doc__.replace(u"exit <type 'type'> <type 'MyException'>",
u"exit <type 'classobj'> <type 'instance'>")
def typename(t): def typename(t):
return u"<type '%s'>" % type(t).__name__ return u"<type '%s'>" % type(t).__name__
......
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