cpython: 694e2708b4a8 (original) (raw)

Mercurial > cpython

changeset 87520:694e2708b4a8

Issue #15204: Silence and check the 'U' mode deprecation warnings in tests. Changed deprecation message in the fileinput module. [#15204]

Serhiy Storchaka storchaka@gmail.com
date Sun, 24 Nov 2013 23:13:26 +0200
parents ead3f5a907bd
children 0d2ac94fa389
files Lib/fileinput.py Lib/test/test_codecs.py Lib/test/test_fileinput.py Lib/test/test_io.py Lib/test/test_zipfile.py
diffstat 5 files changed, 33 insertions(+), 13 deletions(-)[+] [-] Lib/fileinput.py 2 Lib/test/test_codecs.py 4 Lib/test/test_fileinput.py 8 Lib/test/test_io.py 3 Lib/test/test_zipfile.py 29

line wrap: on

line diff

--- a/Lib/fileinput.py +++ b/Lib/fileinput.py @@ -224,7 +224,7 @@ class FileInput: "'r', 'rU', 'U' and 'rb'") if 'U' in mode: import warnings

--- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -602,7 +602,9 @@ class UTF16Test(ReadTest, unittest.TestC self.addCleanup(support.unlink, support.TESTFN) with open(support.TESTFN, 'wb') as fp: fp.write(s)

class UTF16LETest(ReadTest, unittest.TestCase):

--- 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")

--- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -2777,7 +2777,8 @@ class MiscIOTest(unittest.TestCase): self.assertEqual(f.mode, "wb") f.close()

--- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -14,7 +14,7 @@ from random import randint, random, getr from test.support import (TESTFN, findfile, unlink, requires_zlib, requires_bz2, requires_lzma,

TESTFN2 = TESTFN + "2" TESTFNDIR = TESTFN + "d" @@ -35,6 +35,10 @@ def get_files(test): yield f test.assertFalse(f.closed) +def openU(zipfp, fn):

+ class AbstractTestsWithSourceFile: @classmethod def setUpClass(cls): @@ -875,6 +879,17 @@ class OtherTests(unittest.TestCase): data += zipfp.read(info) self.assertIn(data, {b"foobar", b"barfoo"})

+

+ def test_universal_readaheads(self): f = io.BytesIO() @@ -884,7 +899,7 @@ class OtherTests(unittest.TestCase): data2 = b'' with zipfile.ZipFile(f, 'r') as zipfp, [](#l5.44)

@@ -1613,7 +1628,7 @@ class AbstractUniversalNewlineTests: # Read the ZIP archive with zipfile.ZipFile(f, "r") as zipfp: for sep, fn in self.arcfiles.items():

@@ -1627,7 +1642,7 @@ class AbstractUniversalNewlineTests: # Read the ZIP archive with zipfile.ZipFile(f, "r") as zipfp: for sep, fn in self.arcfiles.items():

@@ -1652,7 +1667,7 @@ class AbstractUniversalNewlineTests: # Read the ZIP archive with zipfile.ZipFile(f, "r") as zipfp: for sep, fn in self.arcfiles.items():

@@ -1667,7 +1682,7 @@ class AbstractUniversalNewlineTests: # Read the ZIP archive with zipfile.ZipFile(f, "r") as zipfp: for sep, fn in self.arcfiles.items():

@@ -1682,7 +1697,7 @@ class AbstractUniversalNewlineTests: # Read the ZIP archive with zipfile.ZipFile(f, "r") as zipfp: for sep, fn in self.arcfiles.items():