]> granicus.if.org Git - python/commitdiff
test_posix.test_pipe2() now checks that the O_NONBLOCK flag is set
authorVictor Stinner <vstinner@wyplay.com>
Wed, 28 Aug 2013 10:25:40 +0000 (12:25 +0200)
committerVictor Stinner <vstinner@wyplay.com>
Wed, 28 Aug 2013 10:25:40 +0000 (12:25 +0200)
Use also os.get_inheritable() instead of fcntl() to check the inheritable flag
(FD_CLOEXEC).

Lib/test/test_posix.py

index 3fd8f115cbdb39f3bd6eb19e03ecad6cc9a1e6b9..6cd3393a6376a6db0a2a0179b5fa3c5e4ede4241 100644 (file)
@@ -563,8 +563,10 @@ class PosixTester(unittest.TestCase):
         r, w = os.pipe2(os.O_CLOEXEC|os.O_NONBLOCK)
         self.addCleanup(os.close, r)
         self.addCleanup(os.close, w)
-        self.assertTrue(fcntl.fcntl(r, fcntl.F_GETFD) & fcntl.FD_CLOEXEC)
-        self.assertTrue(fcntl.fcntl(w, fcntl.F_GETFD) & fcntl.FD_CLOEXEC)
+        self.assertFalse(os.get_inheritable(r))
+        self.assertFalse(os.get_inheritable(w))
+        self.assertTrue(fcntl.fcntl(r, fcntl.F_GETFL) & os.O_NONBLOCK)
+        self.assertTrue(fcntl.fcntl(w, fcntl.F_GETFL) & os.O_NONBLOCK)
         # try reading from an empty pipe: this should fail, not block
         self.assertRaises(OSError, os.read, r, 1)
         # try a write big enough to fill-up the pipe: this should either