mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Added tests of "print >> None"
This commit is contained in:
parent
093abe005d
commit
9182b45a5a
2 changed files with 26 additions and 0 deletions
|
@ -23,6 +23,7 @@ extended print_stmt
|
|||
1 2 3
|
||||
1 2 3
|
||||
1 1 1
|
||||
hello world
|
||||
del_stmt
|
||||
pass_stmt
|
||||
flow_stmt
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue