From: Brett Cannon Date: Fri, 29 Oct 2010 23:54:28 +0000 (+0000) Subject: Use a file context manager for test_ioctl. X-Git-Tag: v3.2a4~270 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dff69853af38b01a808a078ec889205733086a12;p=python Use a file context manager for test_ioctl. --- diff --git a/Lib/test/test_ioctl.py b/Lib/test/test_ioctl.py index 6c7ab0c034..817d62675e 100644 --- a/Lib/test/test_ioctl.py +++ b/Lib/test/test_ioctl.py @@ -30,10 +30,10 @@ class IoctlTests(unittest.TestCase): # If this process has been put into the background, TIOCGPGRP returns # the session ID instead of the process group id. ids = (os.getpgrp(), os.getsid(0)) - tty = open("/dev/tty", "r") - r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ") - rpgrp = struct.unpack("i", r)[0] - self.assertIn(rpgrp, ids) + with open("/dev/tty", "r") as tty: + r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ") + rpgrp = struct.unpack("i", r)[0] + self.assertIn(rpgrp, ids) def _check_ioctl_mutate_len(self, nbytes=None): buf = array.array('i')