mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Merged revisions 76720 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r76720 | antoine.pitrou | 2009-12-08 20:46:38 +0100 (mar., 08 déc. 2009) | 3 lines Make test_pipes a little bit more robust. ........
This commit is contained in:
parent
2df5fc7a36
commit
9b14f6044c
1 changed files with 12 additions and 3 deletions
|
@ -2,7 +2,7 @@ import pipes
|
||||||
import os
|
import os
|
||||||
import string
|
import string
|
||||||
import unittest
|
import unittest
|
||||||
from test.support import TESTFN, run_unittest, unlink
|
from test.support import TESTFN, run_unittest, unlink, reap_children
|
||||||
|
|
||||||
if os.name != 'posix':
|
if os.name != 'posix':
|
||||||
raise unittest.SkipTest('pipes module only works on posix')
|
raise unittest.SkipTest('pipes module only works on posix')
|
||||||
|
@ -36,7 +36,11 @@ class SimplePipeTests(unittest.TestCase):
|
||||||
open(TESTFN, 'w').write('hello world #2')
|
open(TESTFN, 'w').write('hello world #2')
|
||||||
t = pipes.Template()
|
t = pipes.Template()
|
||||||
t.append(s_command + ' < $IN', pipes.FILEIN_STDOUT)
|
t.append(s_command + ' < $IN', pipes.FILEIN_STDOUT)
|
||||||
self.assertEqual(t.open(TESTFN, 'r').read(), 'HELLO WORLD #2')
|
f = t.open(TESTFN, 'r')
|
||||||
|
try:
|
||||||
|
self.assertEqual(f.read(), 'HELLO WORLD #2')
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
|
|
||||||
def testEmptyPipeline1(self):
|
def testEmptyPipeline1(self):
|
||||||
# copy through empty pipe
|
# copy through empty pipe
|
||||||
|
@ -52,7 +56,11 @@ class SimplePipeTests(unittest.TestCase):
|
||||||
d = 'empty pipeline test READ'
|
d = 'empty pipeline test READ'
|
||||||
open(TESTFN, 'w').write(d)
|
open(TESTFN, 'w').write(d)
|
||||||
t=pipes.Template()
|
t=pipes.Template()
|
||||||
self.assertEqual(t.open(TESTFN, 'r').read(), d)
|
f = t.open(TESTFN, 'r')
|
||||||
|
try:
|
||||||
|
self.assertEqual(f.read(), d)
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
|
|
||||||
def testEmptyPipeline3(self):
|
def testEmptyPipeline3(self):
|
||||||
# write through empty pipe
|
# write through empty pipe
|
||||||
|
@ -185,6 +193,7 @@ class SimplePipeTests(unittest.TestCase):
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
run_unittest(SimplePipeTests)
|
run_unittest(SimplePipeTests)
|
||||||
|
reap_children()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
test_main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue