[pypy-commit] pypy py3k: test_bz2: Use the "with" statement because del won't close the file

amauryfa noreply at buildbot.pypy.org
Sat Dec 1 12:02:09 CET 2012


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r59154:cb55d14ce808
Date: 2012-11-30 08:57 +0100
http://bitbucket.org/pypy/pypy/changeset/cb55d14ce808/

Log:	test_bz2: Use the "with" statement because del won't close the file
	and exceed ulimit.

diff --git a/lib-python/3.2/test/test_bz2.py b/lib-python/3.2/test/test_bz2.py
--- a/lib-python/3.2/test/test_bz2.py
+++ b/lib-python/3.2/test/test_bz2.py
@@ -221,8 +221,12 @@
         # "Test opening and deleting a file many times"
         self.createTempFile()
         for i in range(10000):
-            o = BZ2File(self.filename)
-            del o
+            if support.check_impl_detail(pypy=True):
+                with BZ2File(self.filename) as o:
+                    pass
+            else:
+                o = BZ2File(self.filename)
+                del o
 
     def testOpenNonexistent(self):
         # "Test opening a nonexistent file"


More information about the pypy-commit mailing list