From: Stefan Behnel Date: Fri, 30 Oct 2009 12:07:57 +0000 (+0100) Subject: various Py3 test fixes after doctest refactoring X-Git-Tag: 0.12.alpha0~8^2~11 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6787f000a18a9880c6c73b18fad0ede6a3302ab9;p=cython.git various Py3 test fixes after doctest refactoring --- diff --git a/tests/run/forfrom.pyx b/tests/run/forfrom.pyx index 3e1b189a..04baed2f 100644 --- a/tests/run/forfrom.pyx +++ b/tests/run/forfrom.pyx @@ -1,12 +1,9 @@ -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 ])) diff --git a/tests/run/index.pyx b/tests/run/index.pyx index 6354ec4b..7003755f 100644 --- a/tests/run/index.pyx +++ b/tests/run/index.pyx @@ -1,9 +1,17 @@ +__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] diff --git a/tests/run/int_literals.pyx b/tests/run/int_literals.pyx index 7e3d8502..0654f931 100644 --- a/tests/run/int_literals.pyx +++ b/tests/run/int_literals.pyx @@ -1,13 +1,21 @@ +__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 diff --git a/tests/run/ishimoto2.pyx b/tests/run/ishimoto2.pyx index d83eb45f..1e2d43a0 100644 --- a/tests/run/ishimoto2.pyx +++ b/tests/run/ishimoto2.pyx @@ -1,6 +1,3 @@ -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 diff --git a/tests/run/modbody.pyx b/tests/run/modbody.pyx index 82f6a647..7ba63a68 100644 --- a/tests/run/modbody.pyx +++ b/tests/run/modbody.pyx @@ -1,18 +1,15 @@ -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 diff --git a/tests/run/new_style_exceptions.pyx b/tests/run/new_style_exceptions.pyx index 73a29e72..6506149a 100644 --- a/tests/run/new_style_exceptions.pyx +++ b/tests/run/new_style_exceptions.pyx @@ -1,14 +1,11 @@ -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: diff --git a/tests/run/r_bowden1.pyx b/tests/run/r_bowden1.pyx index 7d372b57..14851684 100644 --- a/tests/run/r_bowden1.pyx +++ b/tests/run/r_bowden1.pyx @@ -1,19 +1,18 @@ +__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 diff --git a/tests/run/typedfieldbug_T303.pyx b/tests/run/typedfieldbug_T303.pyx index 8a64444f..e80b4ead 100644 --- a/tests/run/typedfieldbug_T303.pyx +++ b/tests/run/typedfieldbug_T303.pyx @@ -1,3 +1,10 @@ +__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