Commit 6787f000 authored by Stefan Behnel's avatar Stefan Behnel

various Py3 test fixes after doctest refactoring

parent d0d88e68
import sys
if sys.version_info[0] >= 3:
__doc__ = __doc__.replace(u" u'", u" '").replace(u' u"', u' "')
def for_else(): def for_else():
""" """
>>> for_else() >>> for_else()
30 30
>>> print( u'*'.join(int_comp()) ) >>> print( int_comp() )
00*01*02 00*01*02
""" """
cdef int i, j=0, k=2 cdef int i, j=0, k=2
...@@ -18,5 +15,5 @@ def for_else(): ...@@ -18,5 +15,5 @@ def for_else():
def int_comp(): def int_comp():
cdef int i cdef int i
return tuple([ u"%02d" % i return u'*'.join(tuple([ u"%02d" % i
for i from 0 <= i < 3 ]) for i from 0 <= i < 3 ]))
__doc__ = u"""
>>> index_object(100, 100)
Traceback (most recent call last):
...
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): elif sys.version_info < (2,5):
__doc__ = __doc__.replace(u"'int' object is unsubscriptable", u'unsubscriptable object') __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):
""" """
>>> index_tuple((1,1,2,3,5), 0) >>> index_tuple((1,1,2,3,5), 0)
...@@ -52,10 +60,6 @@ def index_object(object o, int i): ...@@ -52,10 +60,6 @@ def index_object(object o, int i):
Traceback (most recent call last): Traceback (most recent call last):
... ...
IndexError: string index out of range IndexError: string index out of range
>>> index_object(100, 100)
Traceback (most recent call last):
...
TypeError: 'int' object is unsubscriptable
""" """
return o[i] return o[i]
......
__doc__ = u"""
>>> c_longs()
(1, 1L, -1L, 18446744073709551615L)
>>> py_longs()
(1, 1L, 100000000000000000000000000000000L, -100000000000000000000000000000000L)
"""
import sys
if sys.version_info[0] >= 3:
__doc__ = __doc__.replace(u'L', u'')
import sys import sys
if sys.version_info[0] >= 3: if sys.version_info[0] >= 3:
__doc__ = __doc__.replace(u'L', u'') __doc__ = __doc__.replace(u'L', u'')
def c_longs(): def c_longs():
"""
>>> c_longs()
(1, 1L, -1L, 18446744073709551615L)
"""
cdef long a = 1L cdef long a = 1L
cdef unsigned long ua = 1UL cdef unsigned long ua = 1UL
cdef long long aa = 0xFFFFFFFFFFFFFFFFLL cdef long long aa = 0xFFFFFFFFFFFFFFFFLL
...@@ -16,8 +24,4 @@ def c_longs(): ...@@ -16,8 +24,4 @@ def c_longs():
return a, ua, aa, uaa return a, ua, aa, uaa
def py_longs(): def py_longs():
"""
>>> py_longs()
(1, 1L, 100000000000000000000000000000000L, -100000000000000000000000000000000L)
"""
return 1, 1L, 100000000000000000000000000000000, -100000000000000000000000000000000 return 1, 1L, 100000000000000000000000000000000, -100000000000000000000000000000000
import sys
if sys.version_info[0] >= 3:
__doc__ = __doc__.replace(u" u'", u" '")
class C: class C:
""" """
...@@ -10,8 +7,8 @@ class C: ...@@ -10,8 +7,8 @@ class C:
u'a b' u'a b'
>>> C().xxx(42) >>> C().xxx(42)
42 42
>>> C().xxx() >>> C().xxx() == 'a b'
u'a b' True
""" """
def xxx(self, p=u"a b"): def xxx(self, p=u"a b"):
return p return p
import sys
if sys.version_info[0] >= 3:
__doc__ = __doc__.replace(u" u'", u" '")
def f(): def f():
""" """
>>> f() >>> f()
>>> g >>> g
42 42
>>> x >>> x == 'spam'
u'spam' True
>>> y >>> y == 'eggs'
u'eggs' True
>>> z >>> z == 'spameggs'
u'spameggs' True
""" """
pass pass
......
import sys
if sys.version_info[0] >= 3:
__doc__ = __doc__.replace(u"u'", u"'")
import sys, types import sys, types
def test(obj): def test(obj):
""" """
>>> test(Exception(u'hi')) >>> test(Exception('hi'))
Raising: Exception(u'hi',) Raising: Exception('hi',)
Caught: Exception(u'hi',) Caught: Exception('hi',)
""" """
print u"Raising: %s%r" % (obj.__class__.__name__, obj.args) print u"Raising: %s%r" % (obj.__class__.__name__, obj.args)
try: try:
......
__doc__ = u"""
>>> f(100)
101L
>>> g(3000000000)
3000000001L
"""
import sys import sys
if sys.version_info[0] >= 3: if sys.version_info[0] >= 3:
__doc__ = __doc__.replace(u"L", u"") __doc__ = __doc__.replace(u"L", u"")
def f(x): def f(x):
"""
>>> f(100)
101L
"""
cdef unsigned long long ull cdef unsigned long long ull
ull = x ull = x
return ull + 1 return ull + 1
def g(unsigned long x): def g(unsigned long x):
"""
>>> g(3000000000)
3000000001L
"""
return x + 1 return x + 1
__doc__ = """
>>> readonly()
Traceback (most recent call last):
...
TypeError: readonly attribute
"""
import sys import sys
if sys.version_info[0] >= 3: if sys.version_info[0] >= 3:
__doc__ = __doc__.replace(u'TypeError:', u'AttributeError:') __doc__ = __doc__.replace(u'TypeError:', u'AttributeError:')
...@@ -53,11 +60,5 @@ def longdouble_access(): ...@@ -53,11 +60,5 @@ def longdouble_access():
def readonly(): def readonly():
"""
>>> readonly()
Traceback (most recent call last):
...
TypeError: readonly attribute
"""
c = MyClass() c = MyClass()
c.actual_double = 3 c.actual_double = 3
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