[pypy-commit] pypy default: Test fix: this test used to randomly close file descriptor 1!

arigo noreply at buildbot.pypy.org
Sun Jun 7 22:00:09 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r77943:d7d00adb03ae
Date: 2015-06-07 22:00 +0200
http://bitbucket.org/pypy/pypy/changeset/d7d00adb03ae/

Log:	Test fix: this test used to randomly close file descriptor 1!

diff --git a/pypy/module/_multiprocessing/test/test_connection.py b/pypy/module/_multiprocessing/test/test_connection.py
--- a/pypy/module/_multiprocessing/test/test_connection.py
+++ b/pypy/module/_multiprocessing/test/test_connection.py
@@ -189,9 +189,11 @@
         assert data2 == '\x00\x00\x00\x04defg'
 
     def test_repr(self):
-        import _multiprocessing
-        c = _multiprocessing.Connection(1)
-        assert repr(c) == '<read-write Connection, handle 1>'
+        import _multiprocessing, os
+        fd = os.dup(1)     # closed by Connection.__del__
+        c = _multiprocessing.Connection(fd)
+        assert repr(c) == '<read-write Connection, handle %d>' % fd
         if hasattr(_multiprocessing, 'PipeConnection'):
-            c = _multiprocessing.PipeConnection(1)
-            assert repr(c) == '<read-write PipeConnection, handle 1>'
+            fd = os.dup(1)     # closed by PipeConnection.__del__
+            c = _multiprocessing.PipeConnection(fd)
+            assert repr(c) == '<read-write PipeConnection, handle %d>' % fd


More information about the pypy-commit mailing list