diff options
author | Barry Warsaw <barry@python.org> | 2000-08-29 04:57:10 +0000 |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2000-08-29 04:57:10 +0000 |
commit | 9182b45a5a9670c316f1391bc31f824191d8e3ef (patch) | |
tree | 55e9b15ecb5fd1988e87450cbb6c12b909696bef /Lib/test/test_grammar.py | |
parent | 093abe005d1017540c1c134f0f4107203a3cf8bd (diff) | |
download | cpython-git-9182b45a5a9670c316f1391bc31f824191d8e3ef.tar.gz |
Added tests of "print >> None"
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r-- | Lib/test/test_grammar.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index b0e3da9305..ef7c09b9a5 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: |