summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_gzip.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_gzip.py')
-rw-r--r--Lib/test/test_gzip.py12
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])