From: Stefan Behnel Date: Thu, 15 May 2008 05:19:37 +0000 (+0200) Subject: more test fixes for Py3 X-Git-Tag: 0.9.8rc1~37^2~69 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4257453b9a86b16ae9126b4e2d75ab6df41302d2;p=cython.git more test fixes for Py3 --- diff --git a/tests/run/classkwonlyargs.pyx b/tests/run/classkwonlyargs.pyx index 7246ce77..92c2eba2 100644 --- a/tests/run/classkwonlyargs.pyx +++ b/tests/run/classkwonlyargs.pyx @@ -49,7 +49,7 @@ __doc__ = u""" >>> g(1,2, c=1, e=0, f=2, d=11) >>> g(1,2, c=1, f=2, e=0, x=25) - >>> g(1,2,3) + >>> g(1,2,3) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes at most 3 positional arguments (4 given) >>> g(1,2) @@ -84,6 +84,14 @@ __doc__ = u""" TypeError: required keyword argument 'f' is missing """ +import sys, re +if sys.version_info[0] >= 3: + __doc__ = re.sub(u"Error: (.*)exactly(.*)", u"Error: \\1at most\\2", __doc__) + +import sys, re +if sys.version_info[0] >= 3: + __doc__ = re.sub(u"(ELLIPSIS[^>]*Error: )[^\n]*\n", u"\\1...\n", __doc__, re.M) + class Spam: def b(self, a, b, c): pass diff --git a/tests/run/extkwonlyargs.pyx b/tests/run/extkwonlyargs.pyx index 40d1b7bb..ca7efbae 100644 --- a/tests/run/extkwonlyargs.pyx +++ b/tests/run/extkwonlyargs.pyx @@ -84,6 +84,10 @@ __doc__ = u""" TypeError: required keyword argument 'f' is missing """ +import sys, re +if sys.version_info[0] >= 3: + __doc__ = re.sub(u"Error: (.*)exactly(.*)", u"Error: \\1at most\\2", __doc__) + cdef class Ext: def b(self, a, b, c): pass diff --git a/tests/run/extstarargs.pyx b/tests/run/extstarargs.pyx index ade60abb..b0fb06ec 100644 --- a/tests/run/extstarargs.pyx +++ b/tests/run/extstarargs.pyx @@ -8,7 +8,7 @@ __doc__ = u""" >>> spam(1,2) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes exactly 3 arguments (2 given) - >>> spam(1,2,3,4) #doctest: +ELLIPSIS + >>> spam(1,2,3,4) Traceback (most recent call last): TypeError: function takes exactly 3 arguments (4 given) >>> spam(1,2,3, a=1) #doctest: +ELLIPSIS @@ -30,7 +30,7 @@ __doc__ = u""" >>> swallow(1,2,3) (1, 2, 3, ()) - >>> swallow(1,2,3,4) #doctest: +ELLIPSIS + >>> swallow(1,2,3,4) Traceback (most recent call last): TypeError: function takes at most 3 positional arguments (4 given) >>> swallow(1,2,3, a=1, b=2) @@ -55,10 +55,10 @@ __doc__ = u""" (1,) >>> onlyt(1,2) (1, 2) - >>> onlyt(a=1) #doctest: +ELLIPSIS + >>> onlyt(a=1) Traceback (most recent call last): TypeError: 'a' is an invalid keyword argument for this function - >>> onlyt(1, a=2) #doctest: +ELLIPSIS + >>> onlyt(1, a=2) Traceback (most recent call last): TypeError: 'a' is an invalid keyword argument for this function @@ -66,13 +66,13 @@ __doc__ = u""" (('a', 1),) >>> onlyk(a=1, b=2) (('a', 1), ('b', 2)) - >>> onlyk(1) #doctest: +ELLIPSIS + >>> onlyk(1) Traceback (most recent call last): TypeError: function takes at most 0 positional arguments (1 given) - >>> onlyk(1, 2) #doctest: +ELLIPSIS + >>> onlyk(1, 2) Traceback (most recent call last): TypeError: function takes at most 0 positional arguments (2 given) - >>> onlyk(1, a=1, b=2) #doctest: +ELLIPSIS + >>> onlyk(1, a=1, b=2) Traceback (most recent call last): TypeError: function takes at most 0 positional arguments (1 given) @@ -90,7 +90,11 @@ __doc__ = u""" import sys, re if sys.version_info[0] >= 3: - __doc__ = re.sub(u"Error: (.*)", u"Error: ...", __doc__) + __doc__ = re.sub(u"Error: (.*)exactly(.*)", u"Error: \\1at most\\2", __doc__) + +import sys, re +if sys.version_info[0] >= 3: + __doc__ = re.sub(u"(ELLIPSIS[^>]*Error: )[^\n]*\n", u"\\1...\n", __doc__, re.M) cdef sorteditems(d): l = list(d.items()) diff --git a/tests/run/kwonlyargs.pyx b/tests/run/kwonlyargs.pyx index 58fec354..01bccc58 100644 --- a/tests/run/kwonlyargs.pyx +++ b/tests/run/kwonlyargs.pyx @@ -81,6 +81,10 @@ __doc__ = u""" TypeError: required keyword argument 'f' is missing """ +import sys, re +if sys.version_info[0] >= 3: + __doc__ = re.sub(u"Error: (.*)exactly(.*)", u"Error: \\1at most\\2", __doc__) + def b(a, b, c): pass diff --git a/tests/run/r_addint.pyx b/tests/run/r_addint.pyx index b04d9f77..399e6d75 100644 --- a/tests/run/r_addint.pyx +++ b/tests/run/r_addint.pyx @@ -1,11 +1,11 @@ __doc__ = u""" >>> def test(a, b): - ... print((a, b, add(a, b))) + ... return (a, b, add(a, b)) >>> test(1, 2) (1, 2, 3) - >>> [ repr(f) for f in test(17.3, 88.6) ] - [17.3, 88.6, 105.9] + >>> [ str(f) for f in test(17.3, 88.6) ] + ['17.3', '88.6', '105.9'] >>> test(u"eggs", u"spam") (u'eggs', u'spam', u'eggsspam') """ diff --git a/tests/run/r_toofewargs.pyx b/tests/run/r_toofewargs.pyx index 20acc89d..735fe86f 100644 --- a/tests/run/r_toofewargs.pyx +++ b/tests/run/r_toofewargs.pyx @@ -4,6 +4,10 @@ __doc__ = u""" TypeError: function takes exactly 3 arguments (0 given) """ +import sys, re +if sys.version_info[0] >= 3: + __doc__ = re.sub(u"Error: (.*)exactly(.*)", u"Error: \\1at most\\2", __doc__) + cdef class Spam: def __init__(self, a, b, int c): diff --git a/tests/run/simpcall.pyx b/tests/run/simpcall.pyx index 0ce249ef..5e3f5f9e 100644 --- a/tests/run/simpcall.pyx +++ b/tests/run/simpcall.pyx @@ -4,15 +4,19 @@ __doc__ = u""" Traceback (most recent call last): TypeError: an integer is required - >>> fail0(1,2) + >>> fail0(1,2) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes exactly 2 arguments (0 given) - >>> fail1(1,2) + >>> fail1(1,2) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes exactly 2 arguments (1 given) """ +import sys, re +if sys.version_info[0] >= 3: + __doc__ = re.sub(u"Error: .*exactly.*", u"Error: ...", __doc__) + import sys if sys.version_info[0] < 3: __doc__ = __doc__.replace(u" b'", u" '") diff --git a/tests/run/starargs.pyx b/tests/run/starargs.pyx index 2ccc5da3..5995848a 100644 --- a/tests/run/starargs.pyx +++ b/tests/run/starargs.pyx @@ -4,7 +4,7 @@ __doc__ = u""" >>> spam(1,2) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes exactly 3 arguments (2 given) - >>> spam(1,2,3,4) #doctest: +ELLIPSIS + >>> spam(1,2,3,4) Traceback (most recent call last): TypeError: function takes exactly 3 arguments (4 given) >>> spam(1,2,3, a=1) #doctest: +ELLIPSIS @@ -26,7 +26,7 @@ __doc__ = u""" >>> swallow(1,2,3) (1, 2, 3, ()) - >>> swallow(1,2,3,4) #doctest: +ELLIPSIS + >>> swallow(1,2,3,4) Traceback (most recent call last): TypeError: function takes at most 3 positional arguments (4 given) >>> swallow(1,2,3, a=1, b=2) @@ -51,10 +51,10 @@ __doc__ = u""" (1,) >>> onlyt(1,2) (1, 2) - >>> onlyt(a=1) #doctest: +ELLIPSIS + >>> onlyt(a=1) Traceback (most recent call last): TypeError: 'a' is an invalid keyword argument for this function - >>> onlyt(1, a=2) #doctest: +ELLIPSIS + >>> onlyt(1, a=2) Traceback (most recent call last): TypeError: 'a' is an invalid keyword argument for this function @@ -62,13 +62,13 @@ __doc__ = u""" (('a', 1),) >>> onlyk(a=1, b=2) (('a', 1), ('b', 2)) - >>> onlyk(1) #doctest: +ELLIPSIS + >>> onlyk(1) Traceback (most recent call last): TypeError: function takes at most 0 positional arguments (1 given) - >>> onlyk(1, 2) #doctest: +ELLIPSIS + >>> onlyk(1, 2) Traceback (most recent call last): TypeError: function takes at most 0 positional arguments (2 given) - >>> onlyk(1, a=1, b=2) #doctest: +ELLIPSIS + >>> onlyk(1, a=1, b=2) Traceback (most recent call last): TypeError: function takes at most 0 positional arguments (1 given) @@ -86,7 +86,11 @@ __doc__ = u""" import sys, re if sys.version_info[0] >= 3: - __doc__ = re.sub(u"Error: (.*)", u"Error: ...", __doc__) + __doc__ = re.sub(u"Error: (.*)exactly(.*)", u"Error: \\1at most\\2", __doc__) + +import sys, re +if sys.version_info[0] >= 3: + __doc__ = re.sub(u"(ELLIPSIS[^>]*Error: )[^\n]*\n", u"\\1...\n", __doc__, re.M) cdef sorteditems(d): l = list(d.items())