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