Added tests of "print >> None"

This commit is contained in:
Barry Warsaw 2000-08-29 04:57:10 +00:00
parent 093abe005d
commit 9182b45a5a
2 changed files with 26 additions and 0 deletions

View 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

View 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: