diff options
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_float.py | 4 | ||||
-rw-r--r-- | Lib/test/test_fstring.py | 2 | ||||
-rw-r--r-- | Lib/test/test_gc.py | 2 | ||||
-rw-r--r-- | Lib/test/test_gzip.py | 12 | ||||
-rw-r--r-- | Lib/test/test_hashlib.py | 2 |
5 files changed, 11 insertions, 11 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index 99c81f0..ff4f387 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -729,7 +729,7 @@ class FormatTestCase(unittest.TestCase): @support.requires_IEEE_754 def test_format_testfile(self): - with open(format_testfile) as testfile: + with open(format_testfile, encoding="utf-8") as testfile: for line in testfile: if line.startswith('--'): continue @@ -769,7 +769,7 @@ class FormatTestCase(unittest.TestCase): class ReprTestCase(unittest.TestCase): def test_repr(self): with open(os.path.join(os.path.split(__file__)[0], - 'floating_points.txt')) as floats_file: + 'floating_points.txt'), encoding="utf-8") as floats_file: for line in floats_file: line = line.strip() if not line or line.startswith('#'): diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py index 79e123f..296cb05 100644 --- a/Lib/test/test_fstring.py +++ b/Lib/test/test_fstring.py @@ -1110,7 +1110,7 @@ x = ( # see issue 38964 with temp_cwd() as cwd: file_path = os.path.join(cwd, 't.py') - with open(file_path, 'w') as f: + with open(file_path, 'w', encoding="utf-8") as f: f.write('f"{a b}"') # This generates a SyntaxError _, _, stderr = assert_python_failure(file_path, PYTHONIOENCODING='ascii') diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py index ba66737..ee4fe49 100644 --- a/Lib/test/test_gc.py +++ b/Lib/test/test_gc.py @@ -750,7 +750,7 @@ class GCTests(unittest.TestCase): a.link = a raise SystemExit(0)""" self.addCleanup(unlink, TESTFN) - with open(TESTFN, 'w') as script: + with open(TESTFN, 'w', encoding="utf-8") as script: script.write(code) rc, out, err = assert_python_ok(TESTFN) self.assertEqual(out.strip(), b'__del__ called') 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]) diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index f50a455..0e06fdc 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -82,7 +82,7 @@ URL = "http://www.pythontest.net/hashlib/{}.txt" def read_vectors(hash_name): url = URL.format(hash_name) try: - testdata = support.open_urlresource(url) + testdata = support.open_urlresource(url, encoding="utf-8") except (OSError, HTTPException): raise unittest.SkipTest("Could not retrieve {}".format(url)) with testdata: |