Author: Jesdi <[email protected]>
Branch: fix-test-vmprof-closed-file
Changeset: r96985:ea52b93b8671
Date: 2019-07-13 17:56 +0200
http://bitbucket.org/pypy/pypy/changeset/ea52b93b8671/

Log:    Fix test. Open file for reading

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