]> granicus.if.org Git - python/commitdiff
close file properly
authorBenjamin Peterson <benjamin@python.org>
Sun, 31 Oct 2010 01:35:53 +0000 (01:35 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sun, 31 Oct 2010 01:35:53 +0000 (01:35 +0000)
Lib/test/test_popen.py

index da0c04eee61a0b33ab5206ba46ec7d8406db83ab..accf187b54d7f3e053cbde1240ba60121f4bfb78 100644 (file)
@@ -22,7 +22,8 @@ class PopenTest(unittest.TestCase):
     def _do_test_commandline(self, cmdline, expected):
         cmd = '%s -c "import sys; print(sys.argv)" %s'
         cmd = cmd % (python, cmdline)
-        data = os.popen(cmd).read()
+        with os.popen(cmd) as p:
+            data = p.read()
         got = eval(data)[1:] # strip off argv[0]
         self.assertEqual(got, expected)