summaryrefslogtreecommitdiff
path: root/Lib/test/test_popen.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-12-09 00:01:27 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2009-12-09 00:01:27 +0000
commitac625351643d5732bcaa77844ef1506bf5c978ab (patch)
tree620f07c70671ea90bd42d61ae51d0fcf19a93f34 /Lib/test/test_popen.py
parent9b14f6044ce261ed2c9154d1c8466ff50e697c2e (diff)
downloadcpython-git-ac625351643d5732bcaa77844ef1506bf5c978ab.tar.gz
Issue #7461: objects returned by os.popen() should support the context manager protocol
Diffstat (limited to 'Lib/test/test_popen.py')
-rw-r--r--Lib/test/test_popen.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_popen.py b/Lib/test/test_popen.py
index 99ad41df74..24fb846bef 100644
--- a/Lib/test/test_popen.py
+++ b/Lib/test/test_popen.py
@@ -49,6 +49,14 @@ class PopenTest(unittest.TestCase):
else:
self.assertEqual(os.popen("exit 42").close(), 42 << 8)
+ def test_contextmanager(self):
+ with os.popen("echo hello") as f:
+ self.assertEqual(f.read(), "hello\n")
+
+ def test_iterating(self):
+ with os.popen("echo hello") as f:
+ self.assertEqual(list(f), ["hello\n"])
+
def test_main():
support.run_unittest(PopenTest)