more test fixes
authorStefan Behnel <scoder@users.berlios.de>
Fri, 16 May 2008 18:07:49 +0000 (20:07 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 16 May 2008 18:07:49 +0000 (20:07 +0200)
22 files changed:
tests/run/__getattribute__.pyx
tests/run/__getattribute_subclasses__.pyx
tests/run/cstringmul.pyx
tests/run/dict.pyx
tests/run/kwargproblems.pyx
tests/run/modbody.pyx
tests/run/print.pyx
tests/run/r_argdefault.pyx
tests/run/r_bishop3.pyx
tests/run/r_extcomplex2.pyx
tests/run/r_extstarargs.pyx
tests/run/r_forloop.pyx
tests/run/r_jiba1.pyx
tests/run/r_print.pyx
tests/run/r_pyclass.pyx
tests/run/r_pyclassdefault.pyx
tests/run/r_spamtype.pyx
tests/run/r_starargcall.pyx
tests/run/strfunction.pyx
tests/run/unicodeliterals.pyx
tests/run/unicodeliteralsdefault.pyx
tests/run/unicodeliteralslatin1.pyx

index ea71bc2c920d240fee5cf28c4e9cd57ac55d06b7..da4c1772083c5411476193e7379bdc9cbebb8a45 100644 (file)
@@ -29,7 +29,7 @@ __getattribute__ and __getattr__ special methods for a single class.
 
 cdef class just_getattribute:
     def __getattribute__(self,n):
-        if n == 'bar':
+        if n == u'bar':
             return n
         else:
             raise AttributeError
@@ -39,7 +39,7 @@ cdef class just_getattr:
     def __init__(self):
         self.foo = 10
     def __getattr__(self,n):
-        if n == 'bar':
+        if n == u'bar':
             return n
         else:
             raise AttributeError
@@ -49,12 +49,12 @@ cdef class both:
     def __init__(self):
         self.foo = 10
     def __getattribute__(self,n):
-        if n == 'foo':
+        if n == u'foo':
             return self.foo
         else:
             raise AttributeError
     def __getattr__(self,n):
-        if n == 'bar':
+        if n == u'bar':
             return n
         else:
             raise AttributeError
index a64f3a3c202a3a4f1ba0d38a4097c7d6dde08ea7..68906710f397e291882c84430c49c5b41f57bf27 100644 (file)
@@ -5,16 +5,16 @@ getattr does not override members.
     >>> a = getattr_boring()
     >>> a.boring_member
     10
-    >>> a.resolved_by
-    'getattr_boring'
+    >>> print(a.resolved_by)
+    getattr_boring
 
 getattribute does.
     >>> a = getattribute_boring()
     >>> a.boring_member
     Traceback (most recent call last):
     AttributeError
-    >>> a.resolved_by
-    'getattribute_boring'
+    >>> print(a.resolved_by)
+    getattribute_boring
 
 Is inherited.
     >>> a = boring_boring_getattribute()
@@ -24,8 +24,8 @@ Is inherited.
     >>> a.boring_boring_getattribute_member
     Traceback (most recent call last):
     AttributeError
-    >>> a.resolved_by
-    '_getattribute'
+    >>> print(a.resolved_by)
+    _getattribute
 
 __getattribute__ is always tried first, then __getattr__, regardless of where
 in the inheritance hiarchy they came from.
@@ -33,8 +33,8 @@ in the inheritance hiarchy they came from.
     >>> a.foo
     Traceback (most recent call last):
     AttributeError
-    >>> a.resolved_by
-    'getattribute_boring_boring_getattr'
+    >>> print(a.resolved_by)
+    getattribute_boring_boring_getattr
     >>> a.getattribute_boring_boring_getattr
     True
     >>> a._getattr
@@ -44,8 +44,8 @@ in the inheritance hiarchy they came from.
     >>> a.foo
     Traceback (most recent call last):
     AttributeError
-    >>> a.resolved_by
-    '_getattribute'
+    >>> print(a.resolved_by)
+    _getattribute
     >>> a.getattr_boring_boring_getattribute
     True
     >>> a._getattribute
@@ -60,36 +60,36 @@ cdef class boring:
 
 cdef class getattr_boring(boring):
     def __getattr__(self,n):
-        if n == 'resolved_by':
-            return 'getattr_boring'
-        elif n == 'getattr_boring':
+        if n == u'resolved_by':
+            return u'getattr_boring'
+        elif n == u'getattr_boring':
             return True
         else:
             raise AttributeError
 
 cdef class getattribute_boring(boring):
     def __getattribute__(self,n):
-        if n == 'resolved_by':
-            return 'getattribute_boring'
-        elif n == 'getattribute_boring':
+        if n == u'resolved_by':
+            return u'getattribute_boring'
+        elif n == u'getattribute_boring':
             return True
         else:
             raise AttributeError
 
 cdef class _getattr:
     def __getattr__(self,n):
-        if n == 'resolved_by':
-            return '_getattr'
-        elif n == '_getattr':
+        if n == u'resolved_by':
+            return u'_getattr'
+        elif n == u'_getattr':
             return True
         else:
             raise AttributeError
 
 cdef class _getattribute(boring):
     def __getattribute__(self,n):
-        if n == 'resolved_by':
-            return '_getattribute'
-        elif n == '_getattribute':
+        if n == u'resolved_by':
+            return u'_getattribute'
+        elif n == u'_getattribute':
             return True
         else:
             raise AttributeError
@@ -108,19 +108,18 @@ cdef class boring_boring_getattr(boring_getattr):
 
 cdef class getattribute_boring_boring_getattr(boring_boring_getattr):
     def __getattribute__(self,n):
-        if n == 'resolved_by':
-            return 'getattribute_boring_boring_getattr'
-        elif n == 'getattribute_boring_boring_getattr':
+        if n == u'resolved_by':
+            return u'getattribute_boring_boring_getattr'
+        elif n == u'getattribute_boring_boring_getattr':
             return True
         else:
             raise AttributeError
 
 cdef class getattr_boring_boring_getattribute(boring_boring_getattribute):
     def __getattr__(self,n):
-        if n == 'resolved_by':
-            return 'getattr_boring_boring_getattribute'
-        elif n == 'getattr_boring_boring_getattribute':
+        if n == u'resolved_by':
+            return u'getattr_boring_boring_getattribute'
+        elif n == u'getattr_boring_boring_getattribute':
             return True
         else:
             raise AttributeError
-
index c4c638b84f5c9902775e498442f8290574a6c308..cf40b03980f82042f3f4494e58dee2ac7dd6def5 100644 (file)
@@ -5,6 +5,5 @@ __doc__ = u"""
     tomatotomatotomatotomatotomatotomatotomato
 """
 
-spam = "eggs" * 4
-grail = 7 * "tomato"
-
+spam = u"eggs" * 4
+grail = 7 * u"tomato"
index 6058a9528d5c71906ee094729f13519885be002f..360d77cc578834b107dbdd701e01007e33f7b088 100644 (file)
@@ -11,9 +11,9 @@ __doc__ = u"""
 
     >>> len(constant())
     2
-    >>> constant()['parrot']
-    'resting'
-    >>> constant()['answer']
+    >>> print(constant()['parrot'])
+    resting
+    >>> print(constant()['answer'])
     42
 """
 
@@ -34,6 +34,5 @@ def keyvalues2(key1, value1, key2, value2):
     return d
 
 def constant():
-    d = {"parrot":"resting", "answer":42}
+    d = {u"parrot":u"resting", u"answer":42}
     return d
-    
index e22651cb7f5bfc5b3985b4c2caf0426087f5a2a5..346baaab31089c907ad2d0440369bc4729a83689 100644 (file)
@@ -12,13 +12,18 @@ __doc__ = u"""
     >>> d
     {}
 
-    >>> d = {'arg' : 2}
+    >>> d = {'arg' : 2} # this should be u'arg', but Py2 can't handle it...
     >>> test(**d)
     {'arg': 3}
     >>> d
     {'arg': 2}
 """
 
+import sys
+
 def test(**kw):
-    kw['arg'] = 3
+    if sys.version_info[0] >= 3:
+        kw[u'arg'] = 3
+    else:
+        kw['arg'] = 3
     return kw
index 82a152a0c861fa1e3ef161cafa6b49086753461e..76d2869f302bab56253b499fa2df623e19399204 100644 (file)
@@ -3,19 +3,22 @@ __doc__ = u"""
     >>> g
     42
     >>> x
-    'spam'
+    u'spam'
     >>> y
-    'eggs'
+    u'eggs'
     >>> z
-    'spameggs'
+    u'spameggs'
 """
 
+import sys
+if sys.version_info[0] >= 3:
+    __doc__ = __doc__.replace(u" u'", u" '")
+
 def f():
     pass
     
 g = 42
-x = "spam"
-y = "eggs"
+x = u"spam"
+y = u"eggs"
 if g:
     z = x + y
-
index afcb7829e62b168bfa529e0de0bd39433f0941c5..9937dc3e2cc01d9fd9228da17849875df1834e2d 100644 (file)
@@ -11,5 +11,4 @@ def f(a, b):
     print a
     print a, b
     print a, b,
-    print 42, "spam"
-    
+    print 42, u"spam"
index d321d2abb58a10cc3c2916c47b35ecdc4f75f4ed..4d887703bcc782befb16f2a482a08de316c3204d 100644 (file)
@@ -9,9 +9,9 @@ __doc__ = u"""
 
 def swallow(name = None, airspeed = None, coconuts = None):
     if name is not None:
-        print "This swallow is called", name
+        print u"This swallow is called", name
     if airspeed is not None:
-        print "This swallow is flying at", airspeed, "furlongs per fortnight"
+        print u"This swallow is flying at", airspeed, u"furlongs per fortnight"
     if coconuts is not None:
-        print "This swallow is carrying", coconuts, "coconuts"
+        print u"This swallow is carrying", coconuts, u"coconuts"
 
index d4aa7b366cbb0f203c106cafe68d1e957a8e95d9..8d2133e6ebf489f46880303b2ebbb22b1c911acf 100644 (file)
@@ -18,10 +18,10 @@ cdef class Foo:
 cdef class Fee(Foo):
 
   def bof(self):
-    print 'Fee bof', self.val
+    print u'Fee bof', self.val
 
 
 cdef class Faa(Fee):
 
   def bof(self):
-    print 'Foo bof', self.val
+    print u'Foo bof', self.val
index 53292ff52ddd68af29ed6826d00c5014e9850d8b..fa1ef23236724fed83fbf818518e0626a17e5321 100644 (file)
@@ -17,8 +17,8 @@ cdef extern from "complexobject.h":
         cdef Py_complex cval
     
 def spam(complex c):
-    print "Real:", c.cval.real
-    print "Imag:", c.cval.imag
+    print u"Real:", c.cval.real
+    print u"Imag:", c.cval.imag
 
 def eggs():
     return complex(17, 42)
index 0c4744275b8baf582987628a9f74c34cebf63015..a2a8aa4424c8009d183e8977d7d41967f34770d2 100644 (file)
@@ -33,7 +33,7 @@ __doc__ = u"""
 cdef class Swallow:
 
     def __init__(self, name, airspeed, *args, **kwds):
-        print "Name:", name
-        print "Airspeed:", airspeed
-        print "Extra args:", args
-        print "Extra keywords:", kwds
+        print u"Name:", name
+        print u"Airspeed:", airspeed
+        print u"Extra args:", args
+        print u"Extra keywords:", kwds
index 7fb8dbcfcd57b24b0eec4dcba1e92c2bc24da96f..4dc7b3767dd7a16e7febd517511fbdf7b5e7f78e 100644 (file)
@@ -9,5 +9,5 @@ __doc__ = u"""
 
 def go():
     for i in range(5):
-        print "Spam!"
+        print u"Spam!"
 
index f1bfed6471b42bfba9c3eac3feaa57a479493a4d..35596d1d469b4994b81cdefc911a287ec07d6926 100644 (file)
@@ -8,7 +8,7 @@ __doc__ = u"""
 cdef class Parrot:
 
     cdef void describe(self):
-        print "This parrot is resting."
+        print u"This parrot is resting."
 
     def describe_python(self):
         self.describe()
@@ -16,7 +16,7 @@ cdef class Parrot:
 cdef class Norwegian(Parrot):
 
     cdef void describe(self):
-        print "Lovely plumage!"
+        print u"Lovely plumage!"
 
 def test():
     cdef Parrot p1, p2
index 6a904ad27b583c637feafc147143922f76edc009..ea716dff15b5eabd1b6651ed835099f2089f7379 100644 (file)
@@ -4,5 +4,5 @@ __doc__ = u"""
 """
 
 def frighten():
-    print "NOBODY", "expects", "the Spanish Inquisition!"
+    print u"NOBODY", u"expects", u"the Spanish Inquisition!"
 
index 8ed93e0e59922d8d256e2a5cf9b1ed35373dd1eb..683422459ed9e60d99e26c71b8548ba86c1f0d6d 100644 (file)
@@ -9,7 +9,7 @@ class Spam:
         self.weight = w
 
     def serve(self):
-        print self.weight, "tons of spam!"
+        print self.weight, u"tons of spam!"
 
 def order():
     s = Spam(42)
index 234ac86bf46013583738d6cf952b77a3aa5c1763..bc83f49f7f16f16d3fc752651c4053a0672910c8 100644 (file)
@@ -12,8 +12,8 @@ class CoconutCarrier:
 
     def swallow(self, name = None, airspeed = None, coconuts = None):
         if name is not None:
-            print "This swallow is called", name
+            print u"This swallow is called", name
         if airspeed is not None:
-            print "This swallow is flying at", airspeed, "furlongs per fortnight"
+            print u"This swallow is flying at", airspeed, "furlongs per fortnight"
         if coconuts is not None:
-            print "This swallow is carrying", coconuts, "coconuts"
+            print u"This swallow is carrying", coconuts, "coconuts"
index 70d85ea059b90303d8732195017585ea0fbf747b..cfa94fbb1e2c315be9e504201f729acc13496b9b 100644 (file)
@@ -17,7 +17,7 @@ cdef class Spam:
         self.tons = 17
     
     def __dealloc__(self):
-        print self.tons, "tons of spam is history."
+        print self.tons, u"tons of spam is history."
     
     def get_tons(self):
         return self.tons
index 97fbeb422ab07df1cfd7003873200eb6e24798e3..dbd47ee1ee70e1c0fa0ff499c99349288dad0186 100644 (file)
@@ -5,9 +5,9 @@ __doc__ = u"""
 """
 
 def spam(a, b, c):
-    print "Args:", a, b, c
+    print u"Args:", a, b, c
 
 def eggs():
     spam(*(1,2,3))
-    spam(*["buckle","my","shoe"])
+    spam(*[u"buckle",u"my",u"shoe"])
 
index b0bc01d0497fa60deb154726447d64b0623ded72..3f0ca9d5e29ccaaeb7f2f33f6855849e68bef74d 100644 (file)
@@ -18,7 +18,7 @@ __doc__ = u"""
 
 import sys
 if sys.version_info[0] >= 3:
-    encoding = {'encoding' : 'ASCII'}
+    encoding = {u'encoding' : u'ASCII'}
 else:
     encoding = {}
     __doc__ = __doc__.replace(u" b'", u" '")
index 7c271b738fe46850b5a53b7455a0d6868385099e..2d08606e09be57e9da7eaf0e6683ded3c751c2a5 100644 (file)
@@ -19,7 +19,7 @@ __doc__ = r"""
     u'S\xf8k ik\xfc\xd6\xe4abc'
     >>> null
     u'\x00'
-""".decode("ASCII") + """
+""".decode(u"ASCII") + """
     >>> len(sa)
     3
     >>> len(ua)
@@ -38,7 +38,7 @@ __doc__ = r"""
     12
     >>> len(null)
     1
-""".decode("ASCII") + u"""
+""".decode(u"ASCII") + u"""
     >>> sa == 'abc'
     True
     >>> ua == u'abc'
@@ -76,5 +76,5 @@ d = u'üÖä'
 e = u'\x03\x67\xf8\uf8d2Søk ik'
 f = u'\xf8'
 
-add = u'Søk ik' + u'üÖä' + 'abc'
+add = u'Søk ik' + u'üÖä' + u'abc'
 null = u'\x00'
index 7123ee32f5f116528d6c15b345f1c26c1ef48040..05129fd315aec19b9ea5e56138f78aba5f511c76 100644 (file)
@@ -25,7 +25,7 @@ __doc__ = r"""
     u'S\xf8k ik\xfc\xd6\xe4abc'
     >>> null
     u'\x00'
-""".decode("ASCII") + """
+""".decode(u"ASCII") + """
     >>> len(sa)
     3
     >>> len(ua)
@@ -44,7 +44,7 @@ __doc__ = r"""
     12
     >>> len(null)
     1
-""".decode("ASCII") + u"""
+""".decode(u"ASCII") + u"""
     >>> sa == 'abc'
     True
     >>> ua == u'abc'
@@ -82,5 +82,5 @@ d = u'üÖä'
 e = u'\x03\x67\xf8\uf8d2Søk ik'
 f = u'\xf8'
 
-add = u'Søk ik' + u'üÖä' + 'abc'
+add = u'Søk ik' + u'üÖä' + u'abc'
 null = u'\x00'
index 2ab8a20abeddff8c2c141368b814bf839641873f..ed0817dcc2bae28f8dfce8817b8a7bcfc637c087 100644 (file)
@@ -19,7 +19,7 @@ __doc__ = r"""
     u'S\xf8k ik\xfc\xd6\xe4abc'
     >>> null
     u'\x00'
-""".decode("ASCII") + """
+""".decode(u"ASCII") + """
     >>> len(sa)
     3
     >>> len(ua)
@@ -38,7 +38,7 @@ __doc__ = r"""
     12
     >>> len(null)
     1
-""".decode("ASCII") + u"""
+""".decode(u"ASCII") + u"""
     >>> sa == 'abc'
     True
     >>> ua == u'abc'
@@ -76,5 +76,5 @@ d = u'
 e = u'\x03\x67\xf8\uf8d2Søk ik'
 f = u'\xf8'
 
-add = u'Søk ik' + u'üÖä' + 'abc'
+add = u'Søk ik' + u'üÖä' + u'abc'
 null = u'\x00'