From: Stefan Behnel Date: Wed, 14 May 2008 23:10:24 +0000 (+0200) Subject: more test fixes for Py3 X-Git-Tag: 0.9.8rc1~37^2~70 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fdcaa814d239e0fd0728ed0713945bf45dc95a0a;p=cython.git more test fixes for Py3 --- diff --git a/tests/run/extstarargs.pyx b/tests/run/extstarargs.pyx index 5fe21720..ade60abb 100644 --- a/tests/run/extstarargs.pyx +++ b/tests/run/extstarargs.pyx @@ -5,13 +5,13 @@ __doc__ = u""" >>> spam(1,2,3) (1, 2, 3) - >>> spam(1,2) + >>> spam(1,2) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes exactly 3 arguments (2 given) - >>> spam(1,2,3,4) + >>> spam(1,2,3,4) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes exactly 3 arguments (4 given) - >>> spam(1,2,3, a=1) + >>> spam(1,2,3, a=1) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: 'a' is an invalid keyword argument for this function @@ -21,21 +21,21 @@ __doc__ = u""" (1, 2, 3, (4,)) >>> grail(1,2,3,4,5,6,7,8,9) (1, 2, 3, (4, 5, 6, 7, 8, 9)) - >>> grail(1,2) + >>> grail(1,2) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes exactly 3 arguments (2 given) - >>> grail(1,2,3, a=1) + >>> grail(1,2,3, a=1) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: 'a' is an invalid keyword argument for this function >>> swallow(1,2,3) (1, 2, 3, ()) - >>> swallow(1,2,3,4) + >>> swallow(1,2,3,4) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes at most 3 positional arguments (4 given) >>> swallow(1,2,3, a=1, b=2) (1, 2, 3, (('a', 1), ('b', 2))) - >>> swallow(1,2,3, x=1) + >>> swallow(1,2,3, x=1) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: keyword parameter 'x' was given by position and by name @@ -47,7 +47,7 @@ __doc__ = u""" (1, 2, 3, (), (('a', 1),)) >>> creosote(1,2,3,4, a=1, b=2) (1, 2, 3, (4,), (('a', 1), ('b', 2))) - >>> creosote(1,2,3,4, x=1) + >>> creosote(1,2,3,4, x=1) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: keyword parameter 'x' was given by position and by name @@ -55,10 +55,10 @@ __doc__ = u""" (1,) >>> onlyt(1,2) (1, 2) - >>> onlyt(a=1) + >>> onlyt(a=1) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: 'a' is an invalid keyword argument for this function - >>> onlyt(1, a=2) + >>> onlyt(1, a=2) #doctest: +ELLIPSIS 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) + >>> onlyk(1) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes at most 0 positional arguments (1 given) - >>> onlyk(1, 2) + >>> onlyk(1, 2) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes at most 0 positional arguments (2 given) - >>> onlyk(1, a=1, b=2) + >>> onlyk(1, a=1, b=2) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes at most 0 positional arguments (1 given) @@ -88,8 +88,12 @@ __doc__ = u""" (1, ('a', 1), ('b', 2)) """ +import sys, re +if sys.version_info[0] >= 3: + __doc__ = re.sub(u"Error: (.*)", u"Error: ...", __doc__) + cdef sorteditems(d): - l = d.items() + l = list(d.items()) l.sort() return tuple(l) diff --git a/tests/run/r_addint.pyx b/tests/run/r_addint.pyx index 2d2f3095..b04d9f77 100644 --- a/tests/run/r_addint.pyx +++ b/tests/run/r_addint.pyx @@ -4,8 +4,8 @@ __doc__ = u""" >>> test(1, 2) (1, 2, 3) - >>> test(17.3, 88.6) - (17.3, 88.6, 105.9) + >>> [ repr(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_docstrings.pyx b/tests/run/r_docstrings.pyx index c5efb8f0..de6cf71b 100644 --- a/tests/run/r_docstrings.pyx +++ b/tests/run/r_docstrings.pyx @@ -3,36 +3,36 @@ __doc__ = u""" u'This is a function docstring.' >>> C.__doc__ - 'This is a class docstring.' + u'This is a class docstring.' >>> CS.__doc__ - 'This is a subclass docstring.' + u'This is a subclass docstring.' >>> print(CSS.__doc__) None >>> T.__doc__ - 'This is an extension type docstring.' + u'This is an extension type docstring.' >>> TS.__doc__ - 'This is an extension subtype docstring.' + u'This is an extension subtype docstring.' >>> TSS.__doc__ Compare with standard Python: >>> def f(): - ... 'This is a function docstring.' + ... u'This is a function docstring.' >>> f.__doc__ - 'This is a function docstring.' + u'This is a function docstring.' >>> class C: - ... 'This is a class docstring.' + ... u'This is a class docstring.' >>> class CS(C): - ... 'This is a subclass docstring.' + ... u'This is a subclass docstring.' >>> class CSS(CS): ... pass >>> C.__doc__ - 'This is a class docstring.' + u'This is a class docstring.' >>> CS.__doc__ - 'This is a subclass docstring.' + u'This is a subclass docstring.' >>> CSS.__doc__ """ diff --git a/tests/run/starargs.pyx b/tests/run/starargs.pyx index d5fde52a..2ccc5da3 100644 --- a/tests/run/starargs.pyx +++ b/tests/run/starargs.pyx @@ -1,13 +1,13 @@ __doc__ = u""" >>> spam(1,2,3) (1, 2, 3) - >>> spam(1,2) + >>> spam(1,2) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes exactly 3 arguments (2 given) - >>> spam(1,2,3,4) + >>> spam(1,2,3,4) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes exactly 3 arguments (4 given) - >>> spam(1,2,3, a=1) + >>> spam(1,2,3, a=1) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: 'a' is an invalid keyword argument for this function @@ -17,21 +17,21 @@ __doc__ = u""" (1, 2, 3, (4,)) >>> grail(1,2,3,4,5,6,7,8,9) (1, 2, 3, (4, 5, 6, 7, 8, 9)) - >>> grail(1,2) + >>> grail(1,2) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes exactly 3 arguments (2 given) - >>> grail(1,2,3, a=1) + >>> grail(1,2,3, a=1) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: 'a' is an invalid keyword argument for this function >>> swallow(1,2,3) (1, 2, 3, ()) - >>> swallow(1,2,3,4) + >>> swallow(1,2,3,4) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes at most 3 positional arguments (4 given) >>> swallow(1,2,3, a=1, b=2) (1, 2, 3, (('a', 1), ('b', 2))) - >>> swallow(1,2,3, x=1) + >>> swallow(1,2,3, x=1) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: keyword parameter 'x' was given by position and by name @@ -43,7 +43,7 @@ __doc__ = u""" (1, 2, 3, (), (('a', 1),)) >>> creosote(1,2,3,4, a=1, b=2) (1, 2, 3, (4,), (('a', 1), ('b', 2))) - >>> creosote(1,2,3,4, x=1) + >>> creosote(1,2,3,4, x=1) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: keyword parameter 'x' was given by position and by name @@ -51,10 +51,10 @@ __doc__ = u""" (1,) >>> onlyt(1,2) (1, 2) - >>> onlyt(a=1) + >>> onlyt(a=1) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: 'a' is an invalid keyword argument for this function - >>> onlyt(1, a=2) + >>> onlyt(1, a=2) #doctest: +ELLIPSIS 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) + >>> onlyk(1) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes at most 0 positional arguments (1 given) - >>> onlyk(1, 2) + >>> onlyk(1, 2) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes at most 0 positional arguments (2 given) - >>> onlyk(1, a=1, b=2) + >>> onlyk(1, a=1, b=2) #doctest: +ELLIPSIS Traceback (most recent call last): TypeError: function takes at most 0 positional arguments (1 given) @@ -84,6 +84,10 @@ __doc__ = u""" (1, ('a', 1), ('b', 2)) """ +import sys, re +if sys.version_info[0] >= 3: + __doc__ = re.sub(u"Error: (.*)", u"Error: ...", __doc__) + cdef sorteditems(d): l = list(d.items()) l.sort()