mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
close file properly
This commit is contained in:
parent
556c7355dd
commit
aa7cec0ac4
1 changed files with 2 additions and 1 deletions
|
|
@ -22,7 +22,8 @@ class PopenTest(unittest.TestCase):
|
|||
def _do_test_commandline(self, cmdline, expected):
|
||||
cmd = '%s -c "import sys; print(sys.argv)" %s'
|
||||
cmd = cmd % (python, cmdline)
|
||||
data = os.popen(cmd).read()
|
||||
with os.popen(cmd) as p:
|
||||
data = p.read()
|
||||
got = eval(data)[1:] # strip off argv[0]
|
||||
self.assertEqual(got, expected)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue