[pypy-svn] r50825 - pypy/dist/pypy/module/_file/test

arigo at codespeak.net arigo at codespeak.net
Mon Jan 21 13:10:20 CET 2008


Author: arigo
Date: Mon Jan 21 13:10:20 2008
New Revision: 50825

Modified:
   pypy/dist/pypy/module/_file/test/test_file_extra.py
Log:
Test for previous checkin.


Modified: pypy/dist/pypy/module/_file/test/test_file_extra.py
==============================================================================
--- pypy/dist/pypy/module/_file/test/test_file_extra.py	(original)
+++ pypy/dist/pypy/module/_file/test/test_file_extra.py	Mon Jan 21 13:10:20 2008
@@ -522,6 +522,26 @@
         assert f.tell() == 5
         f.close()
 
+    def test_weakref_dies_before_file_closes(self):
+        # Hard-to-reproduce failure (which should now be fixed).
+        # I think that this is how lib-python/modified-2.4.1/test_file.py
+        # sometimes failed on a Boehm pypy-c.
+        import weakref, gc
+        fn = self.temptestfile
+        f = open(fn, 'wb')
+        f.close()
+        f = open(fn, 'rb')
+        ref = weakref.ref(f)
+        attempts = range(10)
+        del f
+        for i in attempts:
+            f1 = ref()
+            if f1 is None:
+                break     # all gone
+            assert not f1.closed   # if still reachable, should be still open
+            del f1
+            gc.collect()
+
     def test_ValueError(self):
         fn = self.temptestfile
         f = open(fn, 'wb')



More information about the Pypy-commit mailing list