diff options
author | Inada Naoki <songofacandy@gmail.com> | 2021-04-05 04:11:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-05 04:11:23 (GMT) |
commit | c8e5eb904e12010d2302364e1037c24a30f5e241 (patch) | |
tree | ea1ad39012846500bbb9560262c7f9cd464b62f8 /Lib/test/test_imp.py | |
parent | ee952b5c7355cb64179ca9bb77b13e7738132d3d (diff) | |
download | cpython-c8e5eb904e12010d2302364e1037c24a30f5e241.zip cpython-c8e5eb904e12010d2302364e1037c24a30f5e241.tar.gz cpython-c8e5eb904e12010d2302364e1037c24a30f5e241.tar.bz2 |
bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25181)
* Fix test_shutil
* Fix test_imp
* Fix test_import
* Fix test_importlib
Diffstat (limited to 'Lib/test/test_imp.py')
-rw-r--r-- | Lib/test/test_imp.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py index 4781d89..5abe28e 100644 --- a/Lib/test/test_imp.py +++ b/Lib/test/test_imp.py @@ -102,7 +102,7 @@ class ImportTests(unittest.TestCase): temp_mod_name = 'test_imp_helper' sys.path.insert(0, '.') try: - with open(temp_mod_name + '.py', 'w') as file: + with open(temp_mod_name + '.py', 'w', encoding="latin-1") as file: file.write("# coding: cp1252\nu = 'test.test_imp'\n") file, filename, info = imp.find_module(temp_mod_name) file.close() @@ -157,7 +157,7 @@ class ImportTests(unittest.TestCase): # if the curdir is not in sys.path the test fails when run with # ./python ./Lib/test/regrtest.py test_imp sys.path.insert(0, os.curdir) - with open(temp_mod_name + '.py', 'w') as file: + with open(temp_mod_name + '.py', 'w', encoding="utf-8") as file: file.write('a = 1\n') file, filename, info = imp.find_module(temp_mod_name) with file: @@ -185,7 +185,7 @@ class ImportTests(unittest.TestCase): if not os.path.exists(test_package_name): os.mkdir(test_package_name) - with open(init_file_name, 'w') as file: + with open(init_file_name, 'w', encoding="utf-8") as file: file.write('b = 2\n') with warnings.catch_warnings(): warnings.simplefilter('ignore') @@ -310,7 +310,7 @@ class ImportTests(unittest.TestCase): def test_multiple_calls_to_get_data(self): # Issue #18755: make sure multiple calls to get_data() can succeed. loader = imp._LoadSourceCompatibility('imp', imp.__file__, - open(imp.__file__)) + open(imp.__file__, encoding="utf-8")) loader.get_data(imp.__file__) # File should be closed loader.get_data(imp.__file__) # Will need to create a newly opened file |