diff options
author | Georg Brandl <georg@python.org> | 2006-02-19 14:12:34 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-02-19 14:12:34 (GMT) |
commit | c029f873cb170a5525ef78b00b3957e52be41cda (patch) | |
tree | 93fdedcfe2f51f18ecaa80ac0b13fe1d4eb7246c /Lib/test/test_fileinput.py | |
parent | 67e9fb9d7afbd9935322420a7cadd4cb6538dcdf (diff) | |
download | cpython-c029f873cb170a5525ef78b00b3957e52be41cda.zip cpython-c029f873cb170a5525ef78b00b3957e52be41cda.tar.gz cpython-c029f873cb170a5525ef78b00b3957e52be41cda.tar.bz2 |
Patch #1212287: fileinput.input() now has a mode parameter for
specifying the file mode input files should be opened with.
Diffstat (limited to 'Lib/test/test_fileinput.py')
-rw-r--r-- | Lib/test/test_fileinput.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py index be4cb8e..4080a25 100644 --- a/Lib/test/test_fileinput.py +++ b/Lib/test/test_fileinput.py @@ -3,7 +3,7 @@ Tests for fileinput module. Nick Mathewson ''' -from test.test_support import verify, verbose, TESTFN +from test.test_support import verify, verbose, TESTFN, TestFailed import sys, os, re from StringIO import StringIO from fileinput import FileInput @@ -183,3 +183,20 @@ try: verify(fi.fileno() == -1) finally: remove_tempfiles(t1, t2) + +if verbose: + print "17. Specify opening mode" +try: + # invalid mode, should raise ValueError + fi = FileInput(mode="w") + raise TestFailed("FileInput should reject invalid mode argument") +except ValueError: + pass +try: + # try opening in universal newline mode + t1 = writeTmp(1, ["A\nB\r\nC\rD"]) + fi = FileInput(files=t1, mode="U") + lines = list(fi) + verify(lines == ["A\n", "B\n", "C\n", "D"]) +finally: + remove_tempfiles(t1) |