diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/output/test_grammar | 1 | ||||
-rw-r--r-- | Lib/test/test_grammar.py | 25 |
2 files changed, 26 insertions, 0 deletions
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: |