Author: Ronan Lamy <[email protected]>
Branch: 
Changeset: r96986:a9166640dc56
Date: 2019-07-14 08:13 +0000
http://bitbucket.org/pypy/pypy/changeset/a9166640dc56/

Log:    Merged in jesdi/pypy/fix-test-vmprof-closed-file (pull request #654)

        Fix test reading file not open.

diff --git a/pypy/module/_vmprof/test/test__vmprof.py 
b/pypy/module/_vmprof/test/test__vmprof.py
--- a/pypy/module/_vmprof/test/test__vmprof.py
+++ b/pypy/module/_vmprof/test/test__vmprof.py
@@ -111,14 +111,17 @@
     @py.test.mark.xfail(sys.platform.startswith('freebsd'), reason = "not 
implemented")
     def test_get_profile_path(self):
         import _vmprof
-        tmpfile = open(self.tmpfilename, 'wb')
-        assert _vmprof.get_profile_path() is None
-        _vmprof.enable(tmpfile.fileno(), 0.01, 0, 0, 0, 0)
-        path = _vmprof.get_profile_path()
+        with open(self.tmpfilename, "wb") as tmpfile:
+            assert _vmprof.get_profile_path() is None
+            _vmprof.enable(tmpfile.fileno(), 0.01, 0, 0, 0, 0)
+            path = _vmprof.get_profile_path()
+            _vmprof.disable()
+
         if path != tmpfile.name:
             with open(path, "rb") as fd1:
-                assert fd1.read() == tmpfile.read()
-        _vmprof.disable()
+                with open(self.tmpfilename, "rb") as fd2:
+                    assert fd1.read() == fd2.read()
+
         assert _vmprof.get_profile_path() is None
 
     def test_stop_sampling(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to