[pypy-svn] r35583 - pypy/dist/pypy/module/__builtin__/test

arigo at codespeak.net arigo at codespeak.net
Mon Dec 11 17:06:41 CET 2006


Author: arigo
Date: Mon Dec 11 17:06:40 2006
New Revision: 35583

Modified:
   pypy/dist/pypy/module/__builtin__/test/test_builtin.py
Log:
(pedronis, arigo)

Detect if we're running on top of a Python with broken dict lookup
semantics (eating all exceptions) and skip a test that this fact
makes fragile.  (Works with 'pypy-c -A', or with a patched CPython.)


Modified: pypy/dist/pypy/module/__builtin__/test/test_builtin.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/test/test_builtin.py	(original)
+++ pypy/dist/pypy/module/__builtin__/test/test_builtin.py	Mon Dec 11 17:06:40 2006
@@ -2,6 +2,20 @@
 
 
 class AppTestBuiltinApp:
+    def setup_class(cls):
+        class X(object):
+            def __eq__(self, other):
+                raise OverflowError
+            def __hash__(self):
+                return 42
+        d = {X(): 5}
+        try:
+            d[X()]
+        except OverflowError:
+            cls.w_sane_lookup = cls.space.wrap(True)
+        except KeyError:
+            cls.w_sane_lookup = cls.space.wrap(False)
+
     def test_import(self):
         m = __import__('pprint')
         assert m.pformat({}) == '{}'
@@ -268,6 +282,8 @@
         raises(RuntimeError, cmp, c1, c2)
 
     def test_cmp_cyclic(self):
+        if not self.sane_lookup:
+            skip("underlying Python implementation has insane dict lookup")
         a = []; a.append(a)
         b = []; b.append(b)
         from UserList import UserList



More information about the Pypy-commit mailing list