summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2000-08-29 04:57:10 (GMT)
committerBarry Warsaw <barry@python.org>2000-08-29 04:57:10 (GMT)
commit9182b45a5a9670c316f1391bc31f824191d8e3ef (patch)
tree55e9b15ecb5fd1988e87450cbb6c12b909696bef
parent093abe005d1017540c1c134f0f4107203a3cf8bd (diff)
downloadcpython-9182b45a5a9670c316f1391bc31f824191d8e3ef.zip
cpython-9182b45a5a9670c316f1391bc31f824191d8e3ef.tar.gz
cpython-9182b45a5a9670c316f1391bc31f824191d8e3ef.tar.bz2
Added tests of "print >> None"
-rw-r--r--Lib/test/output/test_grammar1
-rw-r--r--Lib/test/test_grammar.py25
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: