From: Barry Warsaw Date: Tue, 29 Aug 2000 04:57:10 +0000 (+0000) Subject: Added tests of "print >> None" X-Git-Tag: v2.0b1~192 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9182b45a5a9670c316f1391bc31f824191d8e3ef;p=thirdparty%2FPython%2Fcpython.git Added tests of "print >> None" --- diff --git a/Lib/test/output/test_grammar b/Lib/test/output/test_grammar index 8a0c5313b002..739d0c5fc188 100644 --- a/Lib/test/output/test_grammar +++ b/Lib/test/output/test_grammar @@ -23,6 +23,7 @@ extended print_stmt 1 2 3 1 2 3 1 1 1 +hello world del_stmt pass_stmt flow_stmt diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index b0e3da93057b..ef7c09b9a57f 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -268,6 +268,31 @@ print >> sys.stdout print >> sys.stdout, 0 or 1, 0 or 1, print >> sys.stdout, 0 or 1 +# test print >> None +class Gulp: + def write(self, msg): pass + +def driver(): + oldstdout = sys.stdout + sys.stdout = Gulp() + try: + tellme(Gulp()) + tellme() + finally: + sys.stdout = oldstdout + +# we should see this once +def tellme(file=sys.stdout): + print >> file, 'hello world' + +driver() + +# we should not see this at all +def tellme(file=None): + print >> file, 'goodbye universe' + +driver() + # syntax errors def check_syntax(statement): try: