Issue #15204: Silence and check the 'U' mode deprecation warnings in tests.

Changed deprecation message in the fileinput module.
This commit is contained in:
Serhiy Storchaka 2013-11-24 23:13:26 +02:00
parent ed8c906127
commit 2480c2ed59
5 changed files with 33 additions and 13 deletions

View file

@ -22,7 +22,7 @@ except ImportError:
from io import StringIO
from fileinput import FileInput, hook_encoded
from test.support import verbose, TESTFN, run_unittest
from test.support import verbose, TESTFN, run_unittest, check_warnings
from test.support import unlink as safe_unlink
@ -224,8 +224,10 @@ class FileInputTests(unittest.TestCase):
try:
# try opening in universal newline mode
t1 = writeTmp(1, [b"A\nB\r\nC\rD"], mode="wb")
fi = FileInput(files=t1, mode="U")
lines = list(fi)
with check_warnings(('', DeprecationWarning)):
fi = FileInput(files=t1, mode="U")
with check_warnings(('', DeprecationWarning)):
lines = list(fi)
self.assertEqual(lines, ["A\n", "B\n", "C\n", "D"])
finally:
remove_tempfiles(t1)