[pypy-svn] r59572 - in pypy/trunk/pypy: . module/struct/test

arigo at codespeak.net arigo at codespeak.net
Thu Oct 30 16:33:38 CET 2008


Author: arigo
Date: Thu Oct 30 16:33:38 2008
New Revision: 59572

Modified:
   pypy/trunk/pypy/conftest.py
   pypy/trunk/pypy/module/struct/test/test_struct.py
Log:
Tweak this test, and the conftest, to pass a bit more
tests when run with -A.


Modified: pypy/trunk/pypy/conftest.py
==============================================================================
--- pypy/trunk/pypy/conftest.py	(original)
+++ pypy/trunk/pypy/conftest.py	Thu Oct 30 16:33:38 2008
@@ -99,6 +99,9 @@
                         if not ok:
                             py.test.skip("cannot runappdirect test: "
                                          "module %r required" % (modname,))
+                else:
+                    if '__pypy__' in value:
+                        py.test.skip("no module __pypy__ on top of CPython")
                 continue
             if info is None:
                 py.test.skip("cannot runappdirect this test on top of CPython")
@@ -369,7 +372,7 @@
                     # if the value is a function living on the class,
                     # don't turn it into a bound method here
                     obj = getwithoutbinding(instance, name)
-                    setattr(w_instance, name[2:], obj)
+                    setattr(instance, name[2:], obj)
                 else:
                     space.setattr(w_instance, space.wrap(name[2:]), 
                                   getattr(instance, name)) 

Modified: pypy/trunk/pypy/module/struct/test/test_struct.py
==============================================================================
--- pypy/trunk/pypy/module/struct/test/test_struct.py	(original)
+++ pypy/trunk/pypy/module/struct/test/test_struct.py	Thu Oct 30 16:33:38 2008
@@ -268,6 +268,7 @@
         and PyPy might disagree on the specific exception raised in a
         specific situation, e.g. struct.error/TypeError/OverflowError.
         """
+        import sys
         calcsize = self.struct.calcsize
         pack = self.struct.pack
         unpack = self.struct.unpack
@@ -287,10 +288,8 @@
             pack("0p")                  # bad '0p' in struct format
         except error:                   # (but ignored on CPython)
             pass
-        try:
-            unpack("0p", "")            # bad '0p' in struct format
-        except error:                   # (but ignored on CPython)
-            pass
+        if '__pypy__' in sys.builtin_module_names:
+            raises(error, unpack, "0p", "")   # segfaults on CPython 2.5.2!
         raises(error, pack, "b", 150)   # argument out of range
         # XXX the accepted ranges still differs between PyPy and CPython
 
@@ -330,6 +329,9 @@
         just like the array module does.  (This is actually used in the
         implementation of our interp-level array module.)
         """
+        import sys
+        if '__pypy__' not in sys.builtin_module_names:
+            skip("PyPy extension")
         data = self.struct.pack("uuu", u'X', u'Y', u'Z')
         assert data == str(buffer(u'XYZ'))
         assert self.struct.unpack("uuu", data) == (u'X', u'Y', u'Z')



More information about the Pypy-commit mailing list