Commit 6fcb8ca7 authored by Stefan Behnel's avatar Stefan Behnel

Py3 test fixes

parent f630c04f
__doc__ = u"""
>>> a = A()
>>> a.foo()
(True, 'yo')
(True, u'yo')
>>> a.foo(False)
(False, 'yo')
>>> a.foo(10, 'yes')
(True, 'yes')
(False, u'yo')
>>> a.foo(10, u'yes')
(True, u'yes')
>>> call0()
(True, u'yo')
>>> call1()
(False, u'yo')
>>> call2()
(False, u'go')
"""
import sys
if sys.version_info[0] >= 3:
__doc__ = __doc__.replace(u"u'", u"'")
cdef class A:
cpdef foo(self, bint a=True, b="yo"):
cpdef foo(self, bint a=True, b=u"yo"):
return a, b
def call0():
a = A()
return a.foo()
def call1():
a = A()
return a.foo(False)
def call2():
a = A()
return a.foo(False, u"go")
......@@ -4,7 +4,9 @@ __doc__ = u"""
class IteratorAndIterateable:
def next(self):
raise ValueError("")
raise ValueError
def __next__(self):
raise ValueError
def __iter__(self):
return self
......@@ -12,6 +14,6 @@ def f():
try:
for x in IteratorAndIterateable():
pass
assert False, "Should not reach this point, iterator has thrown exception"
assert False, u"Should not reach this point, iterator has thrown exception"
except ValueError:
pass
__doc__ = u"""
>>> test_ints(100)
(100, 100, 100)
>>> test_chars("yo")
('a', 'bc', 'yo')
>>> test_chars(None)
>>> test_chars(b'yo')
(b'a', b'bc', b'yo')
>>> test_chars(None) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
TypeError: expected string or Unicode object, NoneType found
TypeError: expected ...
>>> test_struct(-5, -10)
-5 -10 True
1 2 False
"""
import sys
if sys.version_info[0] < 3:
__doc__ = __doc__.replace(u"b'", u"'")
def test_ints(int x):
cdef list L = [1,2,3,x]
cdef int* Li = [1,2,3,x]
......
__doc__ = u"""
>>> do_slice("abcdef".encode(u"ASCII"), 2, 3)
('c', 'cdef', 'ab', 'abcdef')
>>> do_slice("abcdef".encode(u"ASCII"), 0, 5)
('abcde', 'abcdef', '', 'abcdef')
>>> do_slice(b"abcdef", 2, 3)
(b'c', b'cdef', b'ab', b'abcdef')
>>> do_slice(b"abcdef", 0, 5)
(b'abcde', b'abcdef', b'', b'abcdef')
"""
import sys
if sys.version_info[0] < 3:
__doc__ = __doc__.replace(u"(b'", u"('").replace(u" b'", u" '")
def do_slice(s, int i, int j):
cdef char* ss = s
return ss[i:j], ss[i:], ss[:i], ss[:]
......
__doc__ = u"""
import sys
if sys.version_info[0] >= 3:
__doc__ = u"""
>>> test_signed()
3 <class 'int'>
9 <class 'int'>
6 <class 'int'>
12 <class 'int'>
"""
else:
__doc__ = u"""
>>> test_signed()
3 <type 'int'>
9 <type 'long'>
......@@ -6,7 +17,6 @@ __doc__ = u"""
12 <type 'long'>
"""
cdef int i = 1
cdef long l = 2
cdef unsigned int ui = 4
......
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