[Python-checkins] r76720 - python/trunk/Lib/test/test_pipes.py

antoine.pitrou python-checkins at python.org
Tue Dec 8 20:46:38 CET 2009


Author: antoine.pitrou
Date: Tue Dec  8 20:46:38 2009
New Revision: 76720

Log:
Make test_pipes a little bit more robust.



Modified:
   python/trunk/Lib/test/test_pipes.py

Modified: python/trunk/Lib/test/test_pipes.py
==============================================================================
--- python/trunk/Lib/test/test_pipes.py	(original)
+++ python/trunk/Lib/test/test_pipes.py	Tue Dec  8 20:46:38 2009
@@ -2,7 +2,7 @@
 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 @@
         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 @@
         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 @@
 
 def test_main():
     run_unittest(SimplePipeTests)
+    reap_children()
 
 if __name__ == "__main__":
     test_main()


More information about the Python-checkins mailing list