]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
This commit was manufactured by cvs2svn to create branch
authorcvs2svn <tools@python.org>
Mon, 8 Apr 2002 04:42:09 +0000 (04:42 +0000)
committercvs2svn <tools@python.org>
Mon, 8 Apr 2002 04:42:09 +0000 (04:42 +0000)
'release21-maint'.

Lib/test/output/test_popen [new file with mode: 0644]
Lib/test/test_popen.py [new file with mode: 0644]
Lib/this.py [new file with mode: 0644]

diff --git a/Lib/test/output/test_popen b/Lib/test/output/test_popen
new file mode 100644 (file)
index 0000000..db2ac06
--- /dev/null
@@ -0,0 +1,3 @@
+test_popen
+Test popen:
+popen seemed to process the command-line correctly
diff --git a/Lib/test/test_popen.py b/Lib/test/test_popen.py
new file mode 100644 (file)
index 0000000..2681eb0
--- /dev/null
@@ -0,0 +1,36 @@
+#! /usr/bin/env python
+"""Basic tests for os.popen()
+
+  Particularly useful for platforms that fake popen.
+"""
+
+import os
+import sys
+from test_support import TestSkipped
+from os import popen
+
+# Test that command-lines get down as we expect.
+# To do this we execute:
+#    python -c "import sys;print sys.argv" {rest_of_commandline}
+# This results in Python being spawned and printing the sys.argv list.
+# We can then eval() the result of this, and see what each argv was.
+def _do_test_commandline(cmdline, expected):
+    cmd = 'python -c "import sys;print sys.argv" %s' % (cmdline,)
+    data = popen(cmd).read()
+    got = eval(data)[1:] # strip off argv[0]
+    if got != expected:
+        print "Error in popen commandline handling."
+        print " executed '%s', expected '%r', but got '%r'" \
+                                                    % (cmdline, expected, got)
+
+def _test_commandline():
+    _do_test_commandline("foo bar", ["foo", "bar"])
+    _do_test_commandline('foo "spam and eggs" "silly walk"', ["foo", "spam and eggs", "silly walk"])
+    _do_test_commandline('foo "a \\"quoted\\" arg" bar', ["foo", 'a "quoted" arg', "bar"])
+    print "popen seemed to process the command-line correctly"
+
+def main():
+    print "Test popen:"
+    _test_commandline()
+
+main()
diff --git a/Lib/this.py b/Lib/this.py
new file mode 100644 (file)
index 0000000..37754b7
--- /dev/null
@@ -0,0 +1,28 @@
+s = """Gur Mra bs Clguba, ol Gvz Crgref
+
+Ornhgvshy vf orggre guna htyl.
+Rkcyvpvg vf orggre guna vzcyvpvg.
+Fvzcyr vf orggre guna pbzcyrk.
+Pbzcyrk vf orggre guna pbzcyvpngrq.
+Syng vf orggre guna arfgrq.
+Fcnefr vf orggre guna qrafr.
+Ernqnovyvgl pbhagf.
+Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.
+Nygubhtu cenpgvpnyvgl orngf chevgl.
+Reebef fubhyq arire cnff fvyragyl.
+Hayrff rkcyvpvgyl fvyraprq.
+Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff.
+Gurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg.
+Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh'er Qhgpu.
+Abj vf orggre guna arire.
+Nygubhtu arire vf bsgra orggre guna *evtug* abj.
+Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg'f n onq vqrn.
+Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.
+Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!"""
+
+d = {}
+for c in (65, 97):
+    for i in range(26):
+        d[chr(i+c)] = chr((i+13) % 26 + c)
+
+print "".join([d.get(c, c) for c in s])