From: cvs2svn Date: Mon, 8 Apr 2002 04:42:09 +0000 (+0000) Subject: This commit was manufactured by cvs2svn to create branch X-Git-Tag: v2.1.3~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc4afb313a1336024f1c003a3a0227d054c5f67d;p=thirdparty%2FPython%2Fcpython.git This commit was manufactured by cvs2svn to create branch 'release21-maint'. --- diff --git a/Lib/test/output/test_popen b/Lib/test/output/test_popen new file mode 100644 index 000000000000..db2ac06d0acf --- /dev/null +++ b/Lib/test/output/test_popen @@ -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 index 000000000000..2681eb0fe89b --- /dev/null +++ b/Lib/test/test_popen.py @@ -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 index 000000000000..37754b785ab1 --- /dev/null +++ b/Lib/this.py @@ -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])