From: Stefan Behnel Date: Sun, 18 Oct 2009 17:37:13 +0000 (+0200) Subject: Py3 test fixes X-Git-Tag: 0.13.beta0~2^2~121^2~11 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c7a06febe2058d64ed1936d27c3a95c3b04c22bc;p=cython.git Py3 test fixes --- diff --git a/tests/run/for_in_range_T372.pyx b/tests/run/for_in_range_T372.pyx index ce2a92d4..a8fa40d5 100644 --- a/tests/run/for_in_range_T372.pyx +++ b/tests/run/for_in_range_T372.pyx @@ -1,15 +1,30 @@ __doc__ = u""" >>> test_modify() -0 1 2 3 4 +0 +1 +2 +3 +4 + (4, 0) >>> test_fix() -0 1 2 3 4 +0 +1 +2 +3 +4 + 4 >>> test_break() -0 1 2 +0 +1 +2 + (2, 0) >>> test_return() -0 1 2 +0 +1 +2 (2, 0) """ @@ -20,7 +35,7 @@ cimport cython def test_modify(): cdef int i, n = 5 for i in range(n): - print i, + print i n = 0 print return i,n @@ -30,7 +45,7 @@ def test_modify(): def test_fix(): cdef int i for i in range(5): - print i, + print i print return i @@ -39,10 +54,12 @@ def test_fix(): def test_break(): cdef int i, n = 5 for i in range(n): - print i, + print i n = 0 if i == 2: break + else: + print "FAILED!" print return i,n @@ -51,7 +68,7 @@ def test_break(): def test_return(): cdef int i, n = 5 for i in range(n): - print i, + print i n = 0 if i == 2: return i,n diff --git a/tests/run/jarausch1.pyx b/tests/run/jarausch1.pyx index 0c8e3cc9..9081c25e 100644 --- a/tests/run/jarausch1.pyx +++ b/tests/run/jarausch1.pyx @@ -1,10 +1,18 @@ __doc__ = u""" - >>> py_x = br'\\\\' - >>> assert x == py_x + >>> b == br'\\\\' + True + >>> s == r'\\\\' + True + >>> u == ur'\\\\' + True """ import sys if sys.version_info[0] < 3: __doc__ = __doc__.replace(u" br'", u" r'") +else: + __doc__ = __doc__.replace(u" ur'", u" r'") -x = r'\\' +b = br'\\' +s = r'\\' +u = ur'\\' diff --git a/tests/run/kostyrka2.pyx b/tests/run/kostyrka2.pyx index bd6b076c..b89758e3 100644 --- a/tests/run/kostyrka2.pyx +++ b/tests/run/kostyrka2.pyx @@ -1,12 +1,8 @@ __doc__ = u""" >>> x = X() >>> x.slots - [b''] + [''] """ -import sys -if sys.version_info[0] < 3: - __doc__ = __doc__.replace(u"b'", u"'") - class X: slots = ["", ] diff --git a/tests/run/literalslice.pyx b/tests/run/literalslice.pyx index d7102b6c..901ee890 100644 --- a/tests/run/literalslice.pyx +++ b/tests/run/literalslice.pyx @@ -1,6 +1,6 @@ __doc__ = u""" >>> test_str(1) - b'b' + 'b' >>> test_unicode_ascii(2) u'c' @@ -10,14 +10,14 @@ __doc__ = u""" >>> test_int_list(2) 3 >>> test_str_list(1) - b'bcd' + 'bcd' >>> test_int_tuple(2) 3 >>> test_str_tuple(0) - b'a' + 'a' >>> test_mix_tuple(1) - b'abc' + 'abc' >>> test_mix_tuple(0) 1 """ @@ -30,10 +30,7 @@ else: __doc__ = __doc__.replace(u" b'", u" '") def test_str(n): - if IS_PY3: - return bytes(["abcd"[n]]) - else: - return "abcd"[n] + return "abcd"[n] def test_unicode_ascii(n): return u"abcd"[n] diff --git a/tests/run/r_vree_1.pyx b/tests/run/r_vree_1.pyx index fc4a5bc2..1a14c268 100644 --- a/tests/run/r_vree_1.pyx +++ b/tests/run/r_vree_1.pyx @@ -1,10 +1,13 @@ -__doc__ = """# disabled in Py3 + +import sys +if sys.version_info[0] < 3: + __doc__ = u""" + >>> test(0) 0L >>> test(1) 1L - >>> import sys >>> sys.maxint + 1 > sys.maxint True >>> type(sys.maxint * 2 + 1) is long @@ -19,7 +22,16 @@ __doc__ = """# disabled in Py3 True >>> test(256 ** unsigned_long_size() - 1) > sys.maxint True -""" + """ +else: + __doc__ = u""" + >>> test(0) + 0 + >>> test(1) + 1 + >>> test(256 ** unsigned_long_size() - 1) > 0 + True + """ def test(k): cdef unsigned long m diff --git a/tests/run/unicodeliterals.pyx b/tests/run/unicodeliterals.pyx index 75235709..0553f255 100644 --- a/tests/run/unicodeliterals.pyx +++ b/tests/run/unicodeliterals.pyx @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -__doc__ = r""" +__doc__ = br""" >>> sa - b'abc' + 'abc' >>> ua u'abc' >>> b @@ -19,7 +19,7 @@ __doc__ = r""" u'S\xf8k ik\xfc\xd6\xe4abc' >>> null u'\x00' -""".decode(u"ASCII") + """ +""".decode("ASCII") + b""" >>> len(sa) 3 >>> len(ua) @@ -38,7 +38,7 @@ __doc__ = r""" 12 >>> len(null) 1 -""".decode(u"ASCII") + u""" +""".decode("ASCII") + u""" >>> ua == u'abc' True >>> b == u'123' diff --git a/tests/run/unicodeliteralsdefault.pyx b/tests/run/unicodeliteralsdefault.pyx index 9f185c19..18737d54 100644 --- a/tests/run/unicodeliteralsdefault.pyx +++ b/tests/run/unicodeliteralsdefault.pyx @@ -6,9 +6,9 @@ # This file is written in UTF-8, but it has no encoding declaration, # so it just defaults to UTF-8 (PEP 3120). -__doc__ = r""" +__doc__ = br""" >>> sa - b'abc' + 'abc' >>> ua u'abc' >>> b @@ -25,7 +25,7 @@ __doc__ = r""" u'S\xf8k ik\xfc\xd6\xe4abc' >>> null u'\x00' -""".decode(u"ASCII") + """ +""".decode("ASCII") + b""" >>> len(sa) 3 >>> len(ua) @@ -44,7 +44,7 @@ __doc__ = r""" 12 >>> len(null) 1 -""".decode(u"ASCII") + u""" +""".decode("ASCII") + u""" >>> ua == u'abc' True >>> b == u'123' diff --git a/tests/run/unicodeliteralslatin1.pyx b/tests/run/unicodeliteralslatin1.pyx index 45ac6c16..46f708ae 100644 --- a/tests/run/unicodeliteralslatin1.pyx +++ b/tests/run/unicodeliteralslatin1.pyx @@ -1,8 +1,8 @@ # -*- coding: latin-1 -*- -__doc__ = r""" +__doc__ = br""" >>> sa - b'abc' + 'abc' >>> ua u'abc' >>> b @@ -19,7 +19,7 @@ __doc__ = r""" u'S\xf8k ik\xfc\xd6\xe4abc' >>> null u'\x00' -""".decode(u"ASCII") + """ +""".decode("ASCII") + b""" >>> len(sa) 3 >>> len(ua) @@ -38,7 +38,7 @@ __doc__ = r""" 12 >>> len(null) 1 -""".decode(u"ASCII") + u""" +""".decode("ASCII") + u""" >>> ua == u'abc' True >>> b == u'123'