From 2480c2ed593a164fe3a4821a13d5867a0a7102ed Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 24 Nov 2013 23:13:26 +0200 Subject: Issue #15204: Silence and check the 'U' mode deprecation warnings in tests. Changed deprecation message in the fileinput module. --- Lib/test/test_fileinput.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Lib/test/test_fileinput.py') diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py index c5e57d4715..db6082cb12 100644 --- a/Lib/test/test_fileinput.py +++ b/Lib/test/test_fileinput.py @@ -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) -- cgit v1.2.1