summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-12-08 19:46:38 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-12-08 19:46:38 (GMT)
commit29dcdabf40f7642c96169ede9040d50a10926832 (patch)
treed761ab49256afe461bec19cf35c5c5a6f656fc96 /Lib
parentca173e2a0719c174af0195873b67e59abd4230cf (diff)
downloadcpython-29dcdabf40f7642c96169ede9040d50a10926832.zip
cpython-29dcdabf40f7642c96169ede9040d50a10926832.tar.gz
cpython-29dcdabf40f7642c96169ede9040d50a10926832.tar.bz2
Make test_pipes a little bit more robust.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_pipes.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_pipes.py b/Lib/test/test_pipes.py
index 0526159..d1053e8 100644
--- a/Lib/test/test_pipes.py
+++ b/Lib/test/test_pipes.py
@@ -2,7 +2,7 @@ import pipes
import os
import string
import unittest
-from test.test_support import TESTFN, run_unittest, unlink
+from test.test_support import TESTFN, run_unittest, unlink, reap_children
if os.name != 'posix':
raise unittest.SkipTest('pipes module only works on posix')
@@ -36,7 +36,8 @@ class SimplePipeTests(unittest.TestCase):
file(TESTFN, 'w').write('hello world #2')
t = pipes.Template()
t.append(s_command + ' < $IN', pipes.FILEIN_STDOUT)
- self.assertEqual(t.open(TESTFN, 'r').read(), 'HELLO WORLD #2')
+ with t.open(TESTFN, 'r') as f:
+ self.assertEqual(f.read(), 'HELLO WORLD #2')
def testEmptyPipeline1(self):
# copy through empty pipe
@@ -52,7 +53,8 @@ class SimplePipeTests(unittest.TestCase):
d = 'empty pipeline test READ'
file(TESTFN, 'w').write(d)
t=pipes.Template()
- self.assertEqual(t.open(TESTFN, 'r').read(), d)
+ with t.open(TESTFN, 'r') as f:
+ self.assertEqual(f.read(), d)
def testEmptyPipeline3(self):
# write through empty pipe
@@ -185,6 +187,7 @@ class SimplePipeTests(unittest.TestCase):
def test_main():
run_unittest(SimplePipeTests)
+ reap_children()
if __name__ == "__main__":
test_main()