diff options
| author | Inada Naoki <songofacandy@gmail.com> | 2021-04-04 08:01:10 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-04 08:01:10 (GMT) |
| commit | 3caea9adda7f79ab5d4c5a1905ca62b44e0b3b7b (patch) | |
| tree | 78737e7113e2b0a6fd07f20e7a7b751338293615 /Lib/test/test_gzip.py | |
| parent | f8775e4f72240faba3947eea8efdd83ee56ae1fd (diff) | |
| download | cpython-3caea9adda7f79ab5d4c5a1905ca62b44e0b3b7b.zip cpython-3caea9adda7f79ab5d4c5a1905ca62b44e0b3b7b.tar.gz cpython-3caea9adda7f79ab5d4c5a1905ca62b44e0b3b7b.tar.bz2 | |
bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25171)
* Fix test_float
* Fix _osx_support
* Fix test_fstring
* Fix test_gc
* Fix test_gzip
* Fix test_hashlib
* Fix unrelated whitespace issue
Co-authored-by: Ned Deily <nad@python.org>
Diffstat (limited to 'Lib/test/test_gzip.py')
| -rw-r--r-- | Lib/test/test_gzip.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 1dcfa2b..446b61a 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -660,14 +660,14 @@ class TestOpen(BaseTest): def test_text_modes(self): uncompressed = data1.decode("ascii") * 50 uncompressed_raw = uncompressed.replace("\n", os.linesep) - with gzip.open(self.filename, "wt") as f: + with gzip.open(self.filename, "wt", encoding="ascii") as f: f.write(uncompressed) with open(self.filename, "rb") as f: file_data = gzip.decompress(f.read()).decode("ascii") self.assertEqual(file_data, uncompressed_raw) - with gzip.open(self.filename, "rt") as f: + with gzip.open(self.filename, "rt", encoding="ascii") as f: self.assertEqual(f.read(), uncompressed) - with gzip.open(self.filename, "at") as f: + with gzip.open(self.filename, "at", encoding="ascii") as f: f.write(uncompressed) with open(self.filename, "rb") as f: file_data = gzip.decompress(f.read()).decode("ascii") @@ -681,7 +681,7 @@ class TestOpen(BaseTest): self.assertEqual(f.read(), uncompressed_bytes) with gzip.open(io.BytesIO(compressed), "rb") as f: self.assertEqual(f.read(), uncompressed_bytes) - with gzip.open(io.BytesIO(compressed), "rt") as f: + with gzip.open(io.BytesIO(compressed), "rt", encoding="ascii") as f: self.assertEqual(f.read(), uncompressed_str) def test_bad_params(self): @@ -722,9 +722,9 @@ class TestOpen(BaseTest): def test_newline(self): # Test with explicit newline (universal newline mode disabled). uncompressed = data1.decode("ascii") * 50 - with gzip.open(self.filename, "wt", newline="\n") as f: + with gzip.open(self.filename, "wt", encoding="ascii", newline="\n") as f: f.write(uncompressed) - with gzip.open(self.filename, "rt", newline="\r") as f: + with gzip.open(self.filename, "rt", encoding="ascii", newline="\r") as f: self.assertEqual(f.readlines(), [uncompressed]) |
