]> granicus.if.org Git - python/commitdiff
Merged revisions 85987 via svnmerge from
authorBrian Curtin <brian.curtin@gmail.com>
Sat, 30 Oct 2010 21:29:52 +0000 (21:29 +0000)
committerBrian Curtin <brian.curtin@gmail.com>
Sat, 30 Oct 2010 21:29:52 +0000 (21:29 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r85987 | brian.curtin | 2010-10-30 16:24:21 -0500 (Sat, 30 Oct 2010) | 2 lines

  Fix #10257. Clear resource warnings by using os.popen's context manager.
........

Lib/test/test_os.py

index 93cdb4ba863eb52ddad6f3ff8debc486aafa6149..49f554c6056fabc22eb4b0d941a4157bb2db17f2 100644 (file)
@@ -344,8 +344,9 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
     def test_update2(self):
         if os.path.exists("/bin/sh"):
             os.environ.update(HELLO="World")
-            value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip()
-            self.assertEquals(value, "World")
+            with os.popen("/bin/sh -c 'echo $HELLO'") as popen:
+                value = popen.read().strip()
+                self.assertEquals(value, "World")
 
 class WalkTests(unittest.TestCase):
     """Tests for os.walk()."""