From 9182b45a5a9670c316f1391bc31f824191d8e3ef Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Tue, 29 Aug 2000 04:57:10 +0000 Subject: Added tests of "print >> None" --- Lib/test/output/test_grammar | 1 + Lib/test/test_grammar.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/Lib/test/output/test_grammar b/Lib/test/output/test_grammar index 8a0c531..739d0c5 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 b0e3da9..ef7c09b 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: -- cgit v0.12