Commit 1e7a8d0c authored by Stefan Behnel's avatar Stefan Behnel

tons of fixes for the test suite: docstrings must be unicode strings to run in...

tons of fixes for the test suite: docstrings must be unicode strings to run in Py3's doctest (obviously...)

--HG--
rename : tests/compile/withnogil.pyx => tests/run/withnogil.pyx
parent e8d06426
__doc__ = """ __doc__ = u"""
>>> s = Swallow() >>> s = Swallow()
>>> s.spam(1) >>> s.spam(1)
1 42 'grail' True 1 42 'grail' True
......
__doc__ = """ __doc__ = u"""
>>> fiches_CP >>> fiches_CP
[] []
""" """
......
__doc__ = """ __doc__ = u"""
__getattribute__ and __getattr__ special methods for a single class. __getattribute__ and __getattr__ special methods for a single class.
>>> a = just_getattribute() >>> a = just_getattribute()
......
__doc__ = """ __doc__ = u"""
__getattribute__ and __getattr__ special methods and subclasses. __getattribute__ and __getattr__ special methods and subclasses.
getattr does not override members. getattr does not override members.
......
__doc__ = """ __doc__ = u"""
>>> x = 1 >>> x = 1
>>> for i in range(10): >>> for i in range(10):
... x = x + i ... x = x + i
......
__doc__ = """ __doc__ = u"""
>>> f() >>> f()
(30, 22) (30, 22)
""" """
......
__doc__ = """ __doc__ = u"""
>>> f(5) >>> f(5)
5 5
""" """
......
__doc__ = """ __doc__ = u"""
>>> iter(C()) >>> iter(C())
Traceback (most recent call last): Traceback (most recent call last):
TypeError: iter() returned non-iterator of type 'NoneType' TypeError: iter() returned non-iterator of type 'NoneType'
......
__doc__ = """ __doc__ = u"""
>>> test_append([]) >>> test_append([])
None None
None None
......
__doc__ = """ __doc__ = u"""
>>> getg() >>> getg()
5 5
>>> f(42) >>> f(42)
......
__doc__ = """ __doc__ = u"""
>>> f() >>> f()
42 42
""" """
......
__doc__ = """ __doc__ = u"""
>>> f(1, 2, 1) >>> f(1, 2, 1)
>>> f(0, 2, 1) >>> f(0, 2, 1)
Traceback (most recent call last): Traceback (most recent call last):
......
__doc__ = """ __doc__ = u"""
>>> class Test: >>> class Test:
... def __init__(self, i): ... def __init__(self, i):
... self.i = i ... self.i = i
......
__doc__ = """ __doc__ = u"""
>>> m = MyClass() >>> m = MyClass()
>>> m is foo(m) >>> m is foo(m)
True True
......
__doc__ = """ __doc__ = u"""
>>> f(20) >>> f(20)
'20' '20'
>>> f('test') >>> f('test')
......
__doc__ = """ __doc__ = u"""
>>> viking(5) >>> viking(5)
5 5
""" """
......
__doc__ = """ __doc__ = u"""
>>> y >>> y
1 1
>>> y and {} >>> y and {}
......
__doc__ = """ __doc__ = u"""
>>> y >>> y
>>> y or {} >>> y or {}
{} {}
......
__doc__ = """ __doc__ = u"""
>>> m = fmatrix() >>> m = fmatrix()
>>> m[1] = True >>> m[1] = True
>>> m.getfoo() >>> m.getfoo()
......
__doc__ = """ __doc__ = u"""
>>> f = foo() >>> f = foo()
>>> 'a' in f >>> 'a' in f
True True
......
__doc__ = """ __doc__ = u"""
>>> foo(True, False, 23, 'test', 1) >>> foo(True, False, 23, 'test', 1)
(0, 1, False, False) (0, 1, False, False)
""" """
......
__doc__ = """ __doc__ = u"""
>>> test() >>> test()
""" """
......
__doc__ = """ __doc__ = u"""
>>> int2 = 42 >>> int2 = 42
>>> int3 = 7 >>> int3 = 7
>>> char1 = ord('C') >>> char1 = ord('C')
......
__doc__ = """ __doc__ = u"""
>>> spam = Spam() >>> spam = Spam()
>>> b,c,d,e,f,g,h,k = spam.b,spam.c,spam.d,spam.e,spam.f,spam.g,spam.h,spam.k >>> b,c,d,e,f,g,h,k = spam.b,spam.c,spam.d,spam.e,spam.f,spam.g,spam.h,spam.k
......
__doc__ = """ __doc__ = u"""
>>> s = Spam() >>> s = Spam()
>>> print s.__class__.__name__ >>> print s.__class__.__name__
Spam Spam
......
__doc__ = """ __doc__ = u"""
>>> t >>> t
True True
>>> f >>> f
......
__doc__ = """ __doc__ = u"""
>>> spam == "C string 1" + "C string 2" >>> spam == "C string 1" + "C string 2"
True True
""" """
......
__doc__ = """ __doc__ = u"""
>>> print spam >>> print(spam)
eggseggseggseggs eggseggseggseggs
>>> print grail >>> print(grail)
tomatotomatotomatotomatotomatotomatotomato tomatotomatotomatotomatotomatotomatotomato
""" """
......
__doc__ = """ __doc__ = u"""
>>> test_i() >>> test_i()
>>> test_c() >>> test_c()
>>> test_p() >>> test_p()
......
__doc__ = """ __doc__ = u"""
>>> c() >>> c()
120 120
>>> i0() == -1 >>> i0() == -1
......
__doc__ = """ __doc__ = u"""
>>> f() >>> f()
1 1
>>> g() >>> g()
......
__doc__ = """ __doc__ = u"""
>>> test_i() >>> test_i()
>>> test_c() >>> test_c()
>>> test_p() >>> test_p()
......
__doc__ = """ __doc__ = u"""
>>> f() >>> f()
""" """
......
__doc__ = """ __doc__ = u"""
>>> empty() >>> empty()
{} {}
>>> keyvalue(1, 2) >>> keyvalue(1, 2)
......
__doc__ = """ __doc__ = u"""
>>> test() >>> test()
1.0 1.0
""" """
......
__doc__ = """ __doc__ = u"""
>>> p = Point(1,2,3) >>> p = Point(1,2,3)
>>> p.gettuple() >>> p.gettuple()
(1.0, 2.0, 3.0) (1.0, 2.0, 3.0)
......
__doc__ = """ __doc__ = u"""
>>> e = Eggs() >>> e = Eggs()
>>> print type(e).__name__ >>> print type(e).__name__
Eggs Eggs
......
__doc__ = """ __doc__ = u"""
>>> p = create() >>> p = create()
>>> rest(p) >>> rest(p)
0 0
......
__doc__ = """ __doc__ = u"""
>>> print type(f()).__name__ >>> print type(f()).__name__
Spam Spam
""" """
......
__doc__ = """ __doc__ = u"""
>>> ext = Ext() >>> ext = Ext()
>>> b,c,d,e,f,g,h,k = ext.b,ext.c,ext.d,ext.e,ext.f,ext.g,ext.h,ext.k >>> b,c,d,e,f,g,h,k = ext.b,ext.c,ext.d,ext.e,ext.f,ext.g,ext.h,ext.k
......
__doc__ = """ __doc__ = u"""
>>> len(Spam()) >>> len(Spam())
0 0
""" """
......
__doc__ = """ __doc__ = u"""
>>> s = Silly(1,2,3, 'test') >>> s = Silly(1,2,3, 'test')
>>> (spam,grail,swallow,creosote,onlyt,onlyk,tk) = ( >>> (spam,grail,swallow,creosote,onlyt,onlyk,tk) = (
... s.spam,s.grail,s.swallow,s.creosote,s.onlyt,s.onlyk,s.tk) ... s.spam,s.grail,s.swallow,s.creosote,s.onlyt,s.onlyk,s.tk)
......
__doc__ = """ __doc__ = u"""
>>> s = Spam(12) >>> s = Spam(12)
>>> s.eat() >>> s.eat()
12 42 12 42
......
__doc__ = """ __doc__ = u"""
>>> class test(object): a = 1 >>> class test(object): a = 1
>>> t = test() >>> t = test()
......
__doc__ = """ __doc__ = u"""
>>> f(0,0) >>> f(0,0)
0 0
>>> f(1,2) >>> f(1,2)
......
__doc__ = """ __doc__ = u"""
>>> D >>> D
2 2
""" """
......
__doc__ = """ __doc__ = u"""
>>> f(1,[1,2,3]) >>> f(1,[1,2,3])
True True
>>> f(5,[1,2,3]) >>> f(5,[1,2,3])
......
__doc__ = """ __doc__ = u"""
>>> C().xxx(5) >>> C().xxx(5)
5 5
>>> C().xxx() >>> C().xxx()
......
__doc__ = """ __doc__ = u"""
>>> c1 = C1() >>> c1 = C1()
>>> c2 = C2(c1) >>> c2 = C2(c1)
>>> c1 is c2.getc1() >>> c1 is c2.getc1()
......
__doc__ = """ __doc__ = u"""
>>> test_and(None, None) >>> test_and(None, None)
True True
>>> test_and(None, 1) >>> test_and(None, 1)
......
__doc__ = """ __doc__ = u"""
>>> py_x = r'\\\\' >>> py_x = r'\\\\'
>>> assert x == py_x >>> assert x == py_x
""" """
......
__doc__ = """ __doc__ = u"""
>>> t = TEST() >>> t = TEST()
>>> 1 in t >>> 1 in t
True True
......
__doc__ = """ __doc__ = u"""
>>> x = X() >>> x = X()
>>> x.slots >>> x.slots
[''] ['']
......
__doc__ = """ __doc__ = u"""
>>> d = {1 : 2} >>> d = {1 : 2}
>>> test(**d) >>> test(**d)
Traceback (most recent call last): Traceback (most recent call last):
......
__doc__ = """ __doc__ = u"""
>>> b(1,2,3) >>> b(1,2,3)
>>> b(1,2,3,4) >>> b(1,2,3,4)
Traceback (most recent call last): Traceback (most recent call last):
......
__doc__ = """ __doc__ = u"""
>>> a = A(1,2,3) >>> a = A(1,2,3)
>>> a[0] >>> a[0]
1.0 1.0
......
__doc__ = """ __doc__ = u"""
>>> f(1, 2, 3, 4, 5) >>> f(1, 2, 3, 4, 5)
[] []
>>> g(1, 2, 3, 4, 5) >>> g(1, 2, 3, 4, 5)
......
__doc__ = """ __doc__ = u"""
>>> foo() >>> foo()
""" """
......
__doc__ = """ __doc__ = u"""
>>> f() >>> f()
>>> g >>> g
42 42
......
__doc__ = """ __doc__ = u"""
>>> modobj(9,2) >>> modobj(9,2)
1 1
>>> modobj('%d', 5) >>> modobj('%d', 5)
......
__doc__ = """ __doc__ = u"""
>>> f() >>> f()
(1, 2, 1, 2) (1, 2, 1, 2)
>>> g() >>> g()
......
__doc__ = """ __doc__ = u"""
>>> test(Exception('hi')) >>> test(Exception('hi'))
Raising: Exception('hi',) Raising: Exception('hi',)
Caught: Exception('hi',) Caught: Exception('hi',)
......
__doc__ = """ __doc__ = u"""
>>> f(1,[1,2,3]) >>> f(1,[1,2,3])
False False
>>> f(5,[1,2,3]) >>> f(5,[1,2,3])
......
__doc__ = """ __doc__ = u"""
>>> f() >>> f()
""" """
......
__doc__ = """ __doc__ = u"""
>>> test() >>> test()
1 1
""" """
......
__doc__ = """ __doc__ = u"""
>>> x >>> x
(1, 2) (1, 2)
""" """
......
__doc__ = """ __doc__ = u"""
>>> c = build() >>> c = build()
>>> c.method() >>> c.method()
Traceback (most recent call last): Traceback (most recent call last):
......
__doc__ = """ __doc__ = u"""
>>> f = Fiche() >>> f = Fiche()
>>> f[0] = 1 >>> f[0] = 1
>>> f.geti() >>> f.geti()
......
__doc__ = """ __doc__ = u"""
>>> f(1.0, 2.95)[0] == f(1.0, 2.95)[1] >>> f(1.0, 2.95)[0] == f(1.0, 2.95)[1]
True True
......
__doc__ = """ __doc__ = u"""
>>> f(1, 'test') >>> f(1, 'test')
<BLANKLINE> <BLANKLINE>
1 1
......
__doc__ = """ __doc__ = u"""
>>> f() >>> f()
>>> g() >>> g()
""" """
......
__doc__ = """ __doc__ = u"""
>>> s = Spam(Eggs("ham")) >>> s = Spam(Eggs("ham"))
>>> test(s) >>> test(s)
'ham' 'ham'
......
__doc__ = """ __doc__ = u"""
>>> f(1,2,3) >>> f(1,2,3)
3 3
>>> g(1,2,3) >>> g(1,2,3)
......
__doc__ = """ __doc__ = u"""
>>> l1 = Sub1([1,2,3]) >>> l1 = Sub1([1,2,3])
>>> len(l1) >>> len(l1)
3 3
......
__doc__ = """ __doc__ = u"""
>>> f() >>> f()
6 6
>>> g() >>> g()
......
__doc__ = """ __doc__ = u"""
>>> def test(a, b): >>> def test(a, b):
... print a, b, add(a, b) ... print a, b, add(a, b)
......
__doc__ = """ __doc__ = u"""
>>> swallow(name = "Brian") >>> swallow(name = "Brian")
This swallow is called Brian This swallow is called Brian
>>> swallow(airspeed = 42) >>> swallow(airspeed = 42)
......
__doc__ = """ __doc__ = u"""
>>> try: >>> try:
... B() ... B()
... except Exception, e: ... except Exception, e:
......
__doc__ = """ __doc__ = u"""
foo = Foo() >>> foo = Foo()
fee = Fee() >>> fee = Fee()
faa = Faa() >>> faa = Faa()
fee.bof() >>> fee.bof()
faa.bof() Fee bof 0
>>> faa.bof()
Foo bof 0
""" """
cdef class Foo: cdef class Foo:
......
__doc__ = """ __doc__ = u"""
print f(100) >>> print f(100)
print g(3000000000) 101
>>> print g(3000000000)
3000000001
""" """
def f(x): def f(x):
......
__doc__ = """ __doc__ = u"""
try: try:
eggs().eat() eggs().eat()
except RuntimeError, e: except RuntimeError, e:
......
__doc__ = """ __doc__ = u"""
>>> f.__doc__ >>> f.__doc__
'This is a function docstring.' 'This is a function docstring.'
......
__doc__ = """ __doc__ = u"""
>>> c = eggs() >>> c = eggs()
>>> print "eggs returned:", c >>> print "eggs returned:", c
eggs returned: (17+42j) eggs returned: (17+42j)
......
__doc__ = """ __doc__ = u"""
>>> s = Swallow("Brian", 42) >>> s = Swallow("Brian", 42)
Name: Brian Name: Brian
Airspeed: 42 Airspeed: 42
......
__doc__ = """ __doc__ = u"""
>>> go() >>> go()
Spam! Spam!
Spam! Spam!
......
__doc__ = """ __doc__ = u"""
>>> try: >>> try:
... s = Spam() ... s = Spam()
... except StandardError, e: ... except StandardError, e:
......
__doc__ = """ __doc__ = u"""
try: >>> try:
foo() ... foo()
except Exception, e: ... except Exception, e:
print "%s: %s" % (e.__class__.__name__, e) ... print "%s: %s" % (e.__class__.__name__, e)
ValueError:
>>> try:
... bar()
... except Exception, e:
... print "%s: %s" % (e.__class__.__name__, e)
""" """
def bar(): def bar():
......
__doc__ = """ __doc__ = u"""
print r_jeff_epler_1.blowup([2, 3, 5]) >>> blowup([2, 3, 5])
1
""" """
def blowup(p): def blowup(p):
......
__doc__ = """ __doc__ = u"""
>>> test() >>> test()
This parrot is resting. This parrot is resting.
Lovely plumage! Lovely plumage!
......
__doc__ = """ __doc__ = u"""
g = r_lepage_3.Grail() g = r_lepage_3.Grail()
g("spam", 42, ["tomato", "sandwich"]) g("spam", 42, ["tomato", "sandwich"])
""" """
......
__doc__ = """ __doc__ = u"""
>>> import re >>> import re
>>> t >>> t
('2',) ('2',)
......
__doc__ = """ __doc__ = u"""
>>> b = Bicycle() >>> b = Bicycle()
>>> b.fall_off() >>> b.fall_off()
Falling off extremely hard Falling off extremely hard
......
__doc__ = """ __doc__ = u"""
>>> boolExpressionsFail() >>> boolExpressionsFail()
'Not 2b' 'Not 2b'
""" """
......
__doc__ = """ __doc__ = u"""
>>> print primes(20) >>> print primes(20)
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71] [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]
""" """
......
__doc__ = """ __doc__ = u"""
>>> frighten() >>> frighten()
NOBODY expects the Spanish Inquisition! NOBODY expects the Spanish Inquisition!
""" """
......
__doc__ = """ __doc__ = u"""
>>> order() >>> order()
42 tons of spam! 42 tons of spam!
""" """
......
__doc__ = """ __doc__ = u"""
>>> c = CoconutCarrier() >>> c = CoconutCarrier()
>>> c.swallow(name = "Brian") >>> c.swallow(name = "Brian")
This swallow is called Brian This swallow is called Brian
......
__doc__ = """ __doc__ = u"""
>>> x = spam() >>> x = spam()
>>> print repr(x) >>> print repr(x)
'Ftang\\x00Ftang!' 'Ftang\\x00Ftang!'
......
__doc__ = """ __doc__ = u"""
>>> s = Spam() >>> s = Spam()
>>> print s.get_tons() >>> print s.get_tons()
17 17
......
__doc__ = """ __doc__ = u"""
>>> eggs() >>> eggs()
Args: 1 2 3 Args: 1 2 3
Args: buckle my shoe Args: buckle my shoe
......
__doc__ = """ __doc__ = u"""
>>> swallow("Brian", 42) >>> swallow("Brian", 42)
Name: Brian Name: Brian
Airspeed: 42 Airspeed: 42
......
__doc__ = """ __doc__ = u"""
>>> spam() >>> spam()
Args: () Args: ()
>>> spam(42) >>> spam(42)
......
__doc__ = """ __doc__ = u"""
>>> s = Spam() >>> s = Spam()
Traceback (most recent call last): Traceback (most recent call last):
TypeError: function takes exactly 3 arguments (0 given) TypeError: function takes exactly 3 arguments (0 given)
......
__doc__ = """ __doc__ = u"""
>>> test(0) >>> test(0)
0L 0L
>>> test(1) >>> test(1)
......
__doc__ = """ __doc__ = u"""
>>> f() >>> f()
42 42
""" """
......
__doc__ = """ __doc__ = u"""
>>> f('test') >>> f('test')
>>> test_g() >>> test_g()
>>> test_h(5) >>> test_h(5)
......
__doc__ = """ __doc__ = u"""
>>> b = B() >>> b = B()
>>> b.t >>> b.t
{1: ((1, 2, 3),), 2: (1, 2, 3)} {1: ((1, 2, 3),), 2: (1, 2, 3)}
......
__doc__ = """ __doc__ = u"""
>>> z(1,9.2,'test') >>> z(1,9.2,'test')
>>> failtype() >>> failtype()
Traceback (most recent call last): Traceback (most recent call last):
......
__doc__ = """ __doc__ = u"""
>>> f() >>> f()
""" """
......
__doc__ = """ __doc__ = u"""
>>> l = [1,2,3,4] >>> l = [1,2,3,4]
>>> f(1, l, 2, 3) >>> f(1, l, 2, 3)
......
__doc__ = """ __doc__ = u"""
>>> class Test(object): >>> class Test(object):
... def __setitem__(self, key, value): ... def __setitem__(self, key, value):
... print key, value ... print key, value
......
__doc__ = """ __doc__ = u"""
>>> f() >>> f()
12.5 12.5
......
__doc__ = """ __doc__ = u"""
>>> spam(1,2,3) >>> spam(1,2,3)
(1, 2, 3) (1, 2, 3)
>>> spam(1,2) >>> spam(1,2)
......
__doc__ = """ __doc__ = u"""
>>> c = C() >>> c = C()
>>> print c.x >>> print c.x
foo foo
......
__doc__ = """ __doc__ = u"""
>>> s('test') >>> s('test')
'test' 'test'
>>> z >>> z
...@@ -16,20 +16,26 @@ __doc__ = """ ...@@ -16,20 +16,26 @@ __doc__ = """
# 'testing a subtype' # 'testing a subtype'
""" """
import sys
if sys.version_info[0] >= 3:
encoding = {'encoding' : 'ASCII'}
else:
encoding = {}
s = str s = str
z = str('test') z = str('test', **encoding)
def c(string): def c(string):
return str(string) return str(string, **encoding)
class subs(str): class subs(str):
pass pass
def sub(string): def sub(string):
return subs(string) return subs(string, **encoding)
#cdef class subs(str): #cdef class subs(str):
# pass # pass
#def csub(string): #def csub(string):
# return csubs(string) # return csubs(string, **encoding)
__doc__ = """ __doc__ = u"""
>>> f() >>> f()
(-1, -1) (-1, -1)
>>> p() >>> p()
......
__doc__ = """ __doc__ = u"""
>>> f(1,2,3,4,5) >>> f(1,2,3,4,5)
() ()
>>> g(1,2,3,4,5) >>> g(1,2,3,4,5)
......
__doc__ = """ __doc__ = u"""
>>> test1( (1,2,3) ) >>> test1( (1,2,3) )
1 1
>>> test3( (1,2,3) ) >>> test3( (1,2,3) )
......
__doc__ = """ __doc__ = u"""
>>> u('test') >>> u('test')
u'test' u'test'
>>> z >>> z
...@@ -16,6 +16,10 @@ __doc__ = """ ...@@ -16,6 +16,10 @@ __doc__ = """
# u'testing a C subtype' # u'testing a C subtype'
""" """
import sys
if sys.version_info[0] >= 3:
__doc__ = __doc__.replace(u" u'", u" '")
u = unicode u = unicode
z = unicode('test') z = unicode('test')
......
__doc__ = """ __doc__ = u"""
>>> f(1, 2, 3) >>> f(1, 2, 3)
(-3, -4, 1) (-3, -4, 1)
""" """
......
__doc__ = """ __doc__ = u"""
>>> f(1, (2,), (3,4,5), (6,(7,(8,9))), 0) >>> f(1, (2,), (3,4,5), (6,(7,(8,9))), 0)
(8, 9, (8, 9), (6, (7, (8, 9))), 0) (8, 9, (8, 9), (6, (7, (8, 9))), 0)
""" """
......
__doc__ = """ __doc__ = u"""
>>> unpack_normal([1,2]) >>> unpack_normal([1,2])
(1, 2) (1, 2)
>>> unpack_normal([1,2,3]) # doctest: +ELLIPSIS >>> unpack_normal([1,2,3]) # doctest: +ELLIPSIS
......
__doc__ = """ __doc__ = u"""
>>> swallow() >>> swallow()
""" """
......
cdef object f(object x): __doc__ = u"""
>>> f(1)
(1, 17)
>>> g()
1
"""
def f(x):
cdef int y cdef int y
#z = 42 z = 42
with nogil: with nogil:
pass#y = 17 y = 17
#z = 88 z = x
return z,y
cdef object g(): def g():
with nogil: with nogil:
h() h()
return 1
cdef int h() except -1: cdef int h() except -1:
pass pass
__doc__ = """ __doc__ = u"""
>>> x >>> x
5L 5L
""" """
import sys
if sys.version_info[0] >= 3:
__doc__ = __doc__.replace(u"5L'", u"5")
cdef unsigned int ui cdef unsigned int ui
ui = 5 ui = 5
x = ui x = ui
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