[pypy-commit] pypy py3k: Fixes applevel tests to pass with -A.

amauryfa noreply at buildbot.pypy.org
Fri Apr 12 00:21:44 CEST 2013


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r63254:24d0665f1432
Date: 2013-04-12 00:20 +0200
http://bitbucket.org/pypy/pypy/changeset/24d0665f1432/

Log:	Fixes applevel tests to pass with -A.

diff --git a/pypy/objspace/std/test/test_index.py b/pypy/objspace/std/test/test_index.py
--- a/pypy/objspace/std/test/test_index.py
+++ b/pypy/objspace/std/test/test_index.py
@@ -1,44 +1,35 @@
 from py.test import raises
 
 class AppTest_IndexProtocol:
-    def setup_class(self):
-        w_oldstyle = self.space.appexec([], """():
+    def setup_class(cls):
+        cls.w_o = cls.space.appexec([], """():
             class oldstyle:
                 def __index__(self):
                     return self.ind
-            return oldstyle""")
+            return oldstyle()""")
 
-        w_newstyle = self.space.appexec([], """():
+        cls.w_n = cls.space.appexec([], """():
             class newstyle(object):
                 def __index__(self):
                     return self.ind
-            return newstyle""")
+            return newstyle()""")
 
-        w_oldstyle_no_index = self.space.appexec([], """():
+        cls.w_o_no_index = cls.space.appexec([], """():
             class oldstyle_no_index:
                 pass
-            return oldstyle_no_index""")
+            return oldstyle_no_index()""")
 
-        w_newstyle_no_index = self.space.appexec([], """():
+        cls.w_n_no_index = cls.space.appexec([], """():
             class newstyle_no_index(object):
                 pass
-            return newstyle_no_index""")
+            return newstyle_no_index()""")
 
-        w_TrapInt = self.space.appexec([], """(): 
+        cls.w_TrapInt = cls.space.appexec([], """(): 
             class TrapInt(int):
                 def __index__(self):
                     return self
             return TrapInt""")
 
-        self.w_oldstyle = w_oldstyle
-        self.w_o = self.space.call_function(w_oldstyle)
-        self.w_o_no_index = self.space.call_function(w_oldstyle_no_index)
-        self.w_newstyle = w_newstyle
-        self.w_n = self.space.call_function(w_newstyle)
-        self.w_n_no_index = self.space.call_function(w_newstyle_no_index)
-
-        self.w_TrapInt = w_TrapInt
-
     def test_basic(self):
         self.o.ind = -2
         self.n.ind = 2
@@ -92,31 +83,26 @@
     # This test case isn't run directly. It just defines common tests
     # to the different sequence types below
     def setup_method(self, method):
-        w_oldstyle = self.space.appexec([], """():
-            class oldstyle:
-                def __index__(self):
-                    return self.ind
-            return oldstyle""")
+        for name in ('w_o', 'w_o2'):
+            setattr(self, name, self.space.appexec([], """():
+                class oldstyle:
+                    def __index__(self):
+                        return self.ind
+                return oldstyle()"""))
 
-        w_newstyle = self.space.appexec([], """():
-            class newstyle(object):
-                def __index__(self):
-                    return self.ind
-            return newstyle""")
+        for name in ('w_n', 'w_n2'):
+            setattr(self, name, self.space.appexec([], """():
+                class newstyle(object):
+                    def __index__(self):
+                        return self.ind
+                return newstyle()"""))
 
-        w_TrapInt = self.space.appexec([], """(): 
+        self.w_TrapInt = self.space.appexec([], """(): 
             class TrapInt(int):
                 def __index__(self):
                     return self
             return TrapInt""")
 
-        self.w_o = self.space.call_function(w_oldstyle)
-        self.w_n = self.space.call_function(w_newstyle)
-        self.w_o2 = self.space.call_function(w_oldstyle)
-        self.w_n2 = self.space.call_function(w_newstyle)
-
-        self.w_TrapInt = w_TrapInt
-
     def test_index(self):
         self.o.ind = -2
         self.n.ind = 2
@@ -204,6 +190,7 @@
         SeqTestCase.setup_method(self, method)
         self.w_seq = self.space.newtuple([self.space.wrap(x) for x in (0,10,20,30,40,50)])
 
+
 class StringTestCase(object):
     def test_startswith(self):
         self.o.ind = 1
@@ -257,9 +244,9 @@
 
 class AppTest_OverflowTestCase:
 
-    def setup_class(self):
-        self.w_pos = self.space.wrap(2**100)
-        self.w_neg = self.space.wrap(-2**100)
+    def setup_class(cls):
+        cls.w_pos = cls.space.wrap(2**100)
+        cls.w_neg = cls.space.wrap(-2**100)
 
     def test_large_longs(self):
         assert self.pos.__index__() == self.pos
diff --git a/pypy/objspace/std/test/test_newformat.py b/pypy/objspace/std/test/test_newformat.py
--- a/pypy/objspace/std/test/test_newformat.py
+++ b/pypy/objspace/std/test/test_newformat.py
@@ -175,7 +175,8 @@
 class AppTestUnicodeFormat(BaseStringFormatTests):
 
     def setup_class(cls):
-        cls.w_s = cls.space.w_unicode
+        cls.w_s = cls.space.appexec(
+            [], """(): return str""")
 
     def test_string_conversion(self):
         class x(object):
@@ -284,7 +285,8 @@
 class AppTestIntFormatting(BaseIntegralFormattingTest):
 
     def setup_class(cls):
-        cls.w_i = cls.space.w_int
+        cls.w_i = cls.space.appexec(
+            [], """(): return int""")
 
 
 class AppTestFloatFormatting:
diff --git a/pypy/tool/pytest/apptest.py b/pypy/tool/pytest/apptest.py
--- a/pypy/tool/pytest/apptest.py
+++ b/pypy/tool/pytest/apptest.py
@@ -114,7 +114,7 @@
         elif isinstance(value, types.ModuleType):
             name = value.__name__
             defs.append("import %s; self.%s = %s\n" % (name, symbol, name))
-        elif isinstance(value, (str, unicode, int, float, list, dict)):
+        elif isinstance(value, (str, unicode, int, long, float, list, tuple, dict)):
             defs.append("self.%s = %s\n" % (symbol, py3k_repr(value)))
     source = py.code.Source(target_)[1:]
     pyfile = udir.join('src.py')


More information about the pypy-commit mailing list