Kaydet (Commit) 9182b45a authored tarafından Barry Warsaw's avatar Barry Warsaw

Added tests of "print >> None"

üst 093abe00
...@@ -23,6 +23,7 @@ extended print_stmt ...@@ -23,6 +23,7 @@ extended print_stmt
1 2 3 1 2 3
1 2 3 1 2 3
1 1 1 1 1 1
hello world
del_stmt del_stmt
pass_stmt pass_stmt
flow_stmt flow_stmt
......
...@@ -268,6 +268,31 @@ print >> sys.stdout ...@@ -268,6 +268,31 @@ print >> sys.stdout
print >> sys.stdout, 0 or 1, 0 or 1, print >> sys.stdout, 0 or 1, 0 or 1,
print >> sys.stdout, 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 # syntax errors
def check_syntax(statement): def check_syntax(statement):
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment