]> granicus.if.org Git - python/commitdiff
Added tests of "print >> None"
authorBarry Warsaw <barry@python.org>
Tue, 29 Aug 2000 04:57:10 +0000 (04:57 +0000)
committerBarry Warsaw <barry@python.org>
Tue, 29 Aug 2000 04:57:10 +0000 (04:57 +0000)
Lib/test/output/test_grammar
Lib/test/test_grammar.py

index 8a0c5313b002a2ccb6553c5dfa1e6f0e82c89cc0..739d0c5fc1882b199672f9bae4deea763d52e705 100644 (file)
@@ -23,6 +23,7 @@ extended print_stmt
 1 2 3
 1 2 3
 1 1 1
+hello world
 del_stmt
 pass_stmt
 flow_stmt
index b0e3da93057b20db75e584a26c9c519114d9c323..ef7c09b9a57fe8ace098772bd4a1b89a3353a10c 100644 (file)
@@ -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: