]> granicus.if.org Git - python/commitdiff
bpo-32369: test_subprocess: Fix pass_fds check in test_close_fds() (#4920)
authorizbyshev <izbyshev@users.noreply.github.com>
Mon, 18 Dec 2017 20:26:49 +0000 (03:26 +0700)
committerGregory P. Smith <greg@krypto.org>
Mon, 18 Dec 2017 20:26:49 +0000 (12:26 -0800)
The last part of test_close_fds() doesn't match its own comment.
The following assertion always holds because fds_to_keep and open_fds
are disjoint by construction.

self.assertFalse(remaining_fds & fds_to_keep & open_fds,
                 "Some fds not in pass_fds were left open")

Fix the code to match the message in the assertion.

Lib/test/test_subprocess.py

index bd3b9b46f76f08c60c4c43300fd2489ae48644cf..540ad34d3f5ea086d0f455f150797d576e4cf00f 100644 (file)
@@ -2290,11 +2290,11 @@ class POSIXProcessTestCase(BaseTestCase):
         fds_to_keep = set(open_fds.pop() for _ in range(8))
         p = subprocess.Popen([sys.executable, fd_status],
                              stdout=subprocess.PIPE, close_fds=True,
-                             pass_fds=())
+                             pass_fds=fds_to_keep)
         output, ignored = p.communicate()
         remaining_fds = set(map(int, output.split(b',')))
 
-        self.assertFalse(remaining_fds & fds_to_keep & open_fds,
+        self.assertFalse((remaining_fds - fds_to_keep) & open_fds,
                          "Some fds not in pass_fds were left open")
         self.assertIn(1, remaining_fds, "Subprocess failed")