diff -r ffa851df0825 -r 2fb8b9db1c86 symbian-qemu-0.9.1-12/python-2.6.1/Lib/test/test_pipes.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/symbian-qemu-0.9.1-12/python-2.6.1/Lib/test/test_pipes.py Fri Jul 31 15:01:17 2009 +0100 @@ -0,0 +1,190 @@ +import pipes +import os +import string +import unittest +from test.test_support import TESTFN, run_unittest, unlink, TestSkipped + +if os.name != 'posix': + raise TestSkipped('pipes module only works on posix') + +TESTFN2 = TESTFN + "2" + +# tr a-z A-Z is not portable, so make the ranges explicit +s_command = 'tr %s %s' % (string.ascii_lowercase, string.ascii_uppercase) + +class SimplePipeTests(unittest.TestCase): + def tearDown(self): + for f in (TESTFN, TESTFN2): + unlink(f) + + def testSimplePipe1(self): + t = pipes.Template() + t.append(s_command, pipes.STDIN_STDOUT) + f = t.open(TESTFN, 'w') + f.write('hello world #1') + f.close() + self.assertEqual(open(TESTFN).read(), 'HELLO WORLD #1') + + def testSimplePipe2(self): + file(TESTFN, 'w').write('hello world #2') + t = pipes.Template() + t.append(s_command + ' < $IN > $OUT', pipes.FILEIN_FILEOUT) + t.copy(TESTFN, TESTFN2) + self.assertEqual(open(TESTFN2).read(), 'HELLO WORLD #2') + + def testSimplePipe3(self): + 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') + + def testEmptyPipeline1(self): + # copy through empty pipe + d = 'empty pipeline test COPY' + file(TESTFN, 'w').write(d) + file(TESTFN2, 'w').write('') + t=pipes.Template() + t.copy(TESTFN, TESTFN2) + self.assertEqual(open(TESTFN2).read(), d) + + def testEmptyPipeline2(self): + # read through empty pipe + d = 'empty pipeline test READ' + file(TESTFN, 'w').write(d) + t=pipes.Template() + self.assertEqual(t.open(TESTFN, 'r').read(), d) + + def testEmptyPipeline3(self): + # write through empty pipe + d = 'empty pipeline test WRITE' + t = pipes.Template() + t.open(TESTFN, 'w').write(d) + self.assertEqual(open(TESTFN).read(), d) + + def testQuoting(self): + safeunquoted = string.ascii_letters + string.digits + '!@%_-+=:,./' + unsafe = '"`$\\' + + self.assertEqual(pipes.quote(safeunquoted), safeunquoted) + self.assertEqual(pipes.quote('test file name'), "'test file name'") + for u in unsafe: + self.assertEqual(pipes.quote('test%sname' % u), + "'test%sname'" % u) + for u in unsafe: + self.assertEqual(pipes.quote("test%s'name'" % u), + '"test\\%s\'name\'"' % u) + + def testRepr(self): + t = pipes.Template() + self.assertEqual(repr(t), "