summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2010-10-29 23:54:28 (GMT)
committerBrett Cannon <bcannon@gmail.com>2010-10-29 23:54:28 (GMT)
commitdff69853af38b01a808a078ec889205733086a12 (patch)
tree1ca91d1ffc9f345dc13beefc515b781d9b68ff0f
parent5a9e91b050747ff6799f4cb4ed041bbacee8de07 (diff)
downloadcpython-dff69853af38b01a808a078ec889205733086a12.zip
cpython-dff69853af38b01a808a078ec889205733086a12.tar.gz
cpython-dff69853af38b01a808a078ec889205733086a12.tar.bz2
Use a file context manager for test_ioctl.
-rw-r--r--Lib/test/test_ioctl.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/test/test_ioctl.py b/Lib/test/test_ioctl.py
index 6c7ab0c..817d626 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')