[pypy-svn] r28167 - pypy/dist/lib-python/modified-2.4.1/test

ac at codespeak.net ac at codespeak.net
Sat Jun 3 16:21:40 CEST 2006


Author: ac
Date: Sat Jun  3 16:21:39 2006
New Revision: 28167

Modified:
   pypy/dist/lib-python/modified-2.4.1/test/test_weakref.py
Log:
(cfbolz, arre) Rigg some tests :-)

Modified: pypy/dist/lib-python/modified-2.4.1/test/test_weakref.py
==============================================================================
--- pypy/dist/lib-python/modified-2.4.1/test/test_weakref.py	(original)
+++ pypy/dist/lib-python/modified-2.4.1/test/test_weakref.py	Sat Jun  3 16:21:39 2006
@@ -509,7 +509,11 @@
         del c1, c2, C, D
         gc.collect()
 
-    def test_callback_in_cycle_resurrection(self):
+    def XXX_test_callback_in_cycle_resurrection(self):
+        # We can't guarrantee the behaviour tested with our
+        # current weakref implementations.
+        # If an object and a weakref to it gets collected at the
+        # same time it is unclear whether the callback is called.
         import gc
 
         # Do something nasty in a weakref callback:  resurrect objects
@@ -555,7 +559,8 @@
         gc.collect()
         self.assertEqual(alist, [])
 
-    def test_callbacks_on_callback(self):
+    def XXX_test_callbacks_on_callback(self):
+        # See XXX_test_callback_in_cycle_resurrection above
         import gc
 
         # Set up weakref callbacks *on* weakref callbacks.
@@ -600,8 +605,12 @@
         self.check_gc_during_creation(weakref.proxy)
 
     def check_gc_during_creation(self, makeref):
-        thresholds = gc.get_threshold()
-        gc.set_threshold(1, 1, 1)
+        # gc.get/set_threshold does not exist in pypy
+        # The tests calling this function probaly don't test anything
+        # usefull anymore
+        
+        #thresholds = gc.get_threshold()
+        #gc.set_threshold(1, 1, 1)
         gc.collect()
         class A:
             pass
@@ -622,7 +631,7 @@
             weakref.ref(referenced, callback)
 
         finally:
-            gc.set_threshold(*thresholds)
+            pass #gc.set_threshold(*thresholds)
 
 
 class SubclassableWeakrefTestCase(unittest.TestCase):
@@ -705,6 +714,7 @@
         #
         #  This exercises d.copy(), d.items(), d[], del d[], len(d).
         #
+        import gc
         dict, objects = self.make_weak_valued_dict()
         for o in objects:
             self.assert_(weakref.getweakrefcount(o) == 1,
@@ -720,6 +730,7 @@
         del items1, items2
         self.assert_(len(dict) == self.COUNT)
         del objects[0]
+        gc.collect()
         self.assert_(len(dict) == (self.COUNT - 1),
                      "deleting object did not cause dictionary update")
         del objects, o
@@ -736,6 +747,7 @@
         #  This exercises d.copy(), d.items(), d[] = v, d[], del d[],
         #  len(d), d.has_key().
         #
+        import gc
         dict, objects = self.make_weak_keyed_dict()
         for o in objects:
             self.assert_(weakref.getweakrefcount(o) == 1,
@@ -749,6 +761,7 @@
         del items1, items2
         self.assert_(len(dict) == self.COUNT)
         del objects[0]
+        gc.collect()
         self.assert_(len(dict) == (self.COUNT - 1),
                      "deleting object did not cause dictionary update")
         del objects, o



More information about the Pypy-commit mailing list