diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 93cdb4ba863..49f554c6056 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -344,8 +344,9 @@ def tearDown(self): 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()."""