summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-12-09 00:03:16 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-12-09 00:03:16 (GMT)
commit53b44f75c1f7dc2ad5e1ccd0171d8b19bbb3005a (patch)
treeca61fba9c2cbf426593ebe3dbfc0954da3b25fd7 /Lib/test
parent2cfd61a12a2b9753062a4ad9b9aeb76c8b93c19e (diff)
downloadcpython-53b44f75c1f7dc2ad5e1ccd0171d8b19bbb3005a.zip
cpython-53b44f75c1f7dc2ad5e1ccd0171d8b19bbb3005a.tar.gz
cpython-53b44f75c1f7dc2ad5e1ccd0171d8b19bbb3005a.tar.bz2
Merged revisions 76723 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r76723 | antoine.pitrou | 2009-12-09 01:01:27 +0100 (mer., 09 déc. 2009) | 3 lines Issue #7461: objects returned by os.popen() should support the context manager protocol ........
Diffstat (limited to 'Lib/test')
-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 99ad41d..24fb846 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)