Skip to content

Commit 2d8f063

Browse files
izbyshevgpshead
authored andcommitted
bpo-32369: test_subprocess: Fix pass_fds check in test_close_fds() (#4920)
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.
1 parent 02e4b7f commit 2d8f063

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Lib/test/test_subprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,11 +2290,11 @@ def test_close_fds(self):
22902290
fds_to_keep = set(open_fds.pop() for _ in range(8))
22912291
p = subprocess.Popen([sys.executable, fd_status],
22922292
stdout=subprocess.PIPE, close_fds=True,
2293-
pass_fds=())
2293+
pass_fds=fds_to_keep)
22942294
output, ignored = p.communicate()
22952295
remaining_fds = set(map(int, output.split(b',')))
22962296

2297-
self.assertFalse(remaining_fds & fds_to_keep & open_fds,
2297+
self.assertFalse((remaining_fds - fds_to_keep) & open_fds,
22982298
"Some fds not in pass_fds were left open")
22992299
self.assertIn(1, remaining_fds, "Subprocess failed")
23002300

0 commit comments

Comments
 (0)