mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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 ........
This commit is contained in:
parent
2cfd61a12a
commit
53b44f75c1
2 changed files with 12 additions and 0 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue