[pypy-svn] pypy default: a test to check that a mapdict instance keeps its class alive. fails currently.

cfbolz commits-noreply at bitbucket.org
Tue Feb 15 15:52:27 CET 2011


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: 
Changeset: r41955:db9bc5957db6
Date: 2011-02-15 15:48 +0100
http://bitbucket.org/pypy/pypy/changeset/db9bc5957db6/

Log:	a test to check that a mapdict instance keeps its class alive. fails
	currently.

diff --git a/pypy/objspace/std/test/test_mapdict.py b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -884,6 +884,20 @@
             return 42
         f()
 
+    def test_instance_keeps_class_alive(self):
+        import weakref
+        import gc
+        def f():
+            class C(object):
+                def m(self):
+                    42
+            r = weakref.ref(C)
+            c = C()
+            del C
+            gc.collect(); gc.collect(); gc.collect()
+            return c.m()
+        val = f()
+        assert val == 42
 
 class AppTestGlobalCaching(AppTestWithMapDict):
     def setup_class(cls):


More information about the Pypy-commit mailing list