mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-22831: Use "with" to avoid possible fd leaks in tests (part 2). (GH-10929)
This commit is contained in:
parent
9e4861f523
commit
5b10b98247
25 changed files with 253 additions and 312 deletions
|
@ -11,9 +11,9 @@ try:
|
|||
except OSError:
|
||||
raise unittest.SkipTest("Unable to open /dev/tty")
|
||||
else:
|
||||
# Skip if another process is in foreground
|
||||
r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ")
|
||||
tty.close()
|
||||
with tty:
|
||||
# Skip if another process is in foreground
|
||||
r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ")
|
||||
rpgrp = struct.unpack("i", r)[0]
|
||||
if rpgrp not in (os.getpgrp(), os.getsid(0)):
|
||||
raise unittest.SkipTest("Neither the process group nor the session "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue