Commit dff69853 authored by Brett Cannon's avatar Brett Cannon

Use a file context manager for test_ioctl.

parent 5a9e91b0
...@@ -30,10 +30,10 @@ class IoctlTests(unittest.TestCase): ...@@ -30,10 +30,10 @@ class IoctlTests(unittest.TestCase):
# If this process has been put into the background, TIOCGPGRP returns # If this process has been put into the background, TIOCGPGRP returns
# the session ID instead of the process group id. # the session ID instead of the process group id.
ids = (os.getpgrp(), os.getsid(0)) ids = (os.getpgrp(), os.getsid(0))
tty = open("/dev/tty", "r") with open("/dev/tty", "r") as tty:
r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ") r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ")
rpgrp = struct.unpack("i", r)[0] rpgrp = struct.unpack("i", r)[0]
self.assertIn(rpgrp, ids) self.assertIn(rpgrp, ids)
def _check_ioctl_mutate_len(self, nbytes=None): def _check_ioctl_mutate_len(self, nbytes=None):
buf = array.array('i') buf = array.array('i')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment