[Python-checkins] r85957 - python/branches/py3k/Lib/test/test_ioctl.py

brett.cannon python-checkins at python.org
Sat Oct 30 01:54:28 CEST 2010


Author: brett.cannon
Date: Sat Oct 30 01:54:28 2010
New Revision: 85957

Log:
Use a file context manager for test_ioctl.

Modified:
   python/branches/py3k/Lib/test/test_ioctl.py

Modified: python/branches/py3k/Lib/test/test_ioctl.py
==============================================================================
--- python/branches/py3k/Lib/test/test_ioctl.py	(original)
+++ python/branches/py3k/Lib/test/test_ioctl.py	Sat Oct 30 01:54:28 2010
@@ -30,10 +30,10 @@
         # 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')


More information about the Python-checkins mailing list