diff options
author | Inada Naoki <songofacandy@gmail.com> | 2021-04-04 09:01:23 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-04 09:01:23 +0900 |
commit | 35715d1e72b7e15e337087863c75af447199e0fb (patch) | |
tree | 2af3473ba410ffc4b83d74df4d0776814095f25d /Lib/test/_test_multiprocessing.py | |
parent | dc6d3e1e4c0c1e4b2210edab8fb4762569dc2936 (diff) | |
download | cpython-35715d1e72b7e15e337087863c75af447199e0fb.tar.gz cpython-35715d1e72b7e15e337087863c75af447199e0fb.zip |
bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25145)
* test_asyncio
* test_bz2
* test_math
* test_cmath
* test_cmd_line
* test_cmd_line_script
* test_compile
* test_contextlib
* test_profile
* ctypes/test/test_find
* test_multiprocessing
* test_configparser
* test_csv
* test_dbm_dumb
* test_decimal
* test_difflib
* os.fdopen() calls io.text_encoding() to emit EncodingWarning for right place.
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r-- | Lib/test/_test_multiprocessing.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index fd3b4303f03..ead92cfa2ab 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -826,7 +826,7 @@ class _TestSubclassingProcess(BaseTestCase): proc = self.Process(target=self._test_stderr_flush, args=(testfn,)) proc.start() proc.join() - with open(testfn, 'r') as f: + with open(testfn, encoding="utf-8") as f: err = f.read() # The whole traceback was printed self.assertIn("ZeroDivisionError", err) @@ -836,14 +836,14 @@ class _TestSubclassingProcess(BaseTestCase): @classmethod def _test_stderr_flush(cls, testfn): fd = os.open(testfn, os.O_WRONLY | os.O_CREAT | os.O_EXCL) - sys.stderr = open(fd, 'w', closefd=False) + sys.stderr = open(fd, 'w', encoding="utf-8", closefd=False) 1/0 # MARKER @classmethod def _test_sys_exit(cls, reason, testfn): fd = os.open(testfn, os.O_WRONLY | os.O_CREAT | os.O_EXCL) - sys.stderr = open(fd, 'w', closefd=False) + sys.stderr = open(fd, 'w', encoding="utf-8", closefd=False) sys.exit(reason) def test_sys_exit(self): @@ -864,7 +864,7 @@ class _TestSubclassingProcess(BaseTestCase): join_process(p) self.assertEqual(p.exitcode, 1) - with open(testfn, 'r') as f: + with open(testfn, encoding="utf-8") as f: content = f.read() self.assertEqual(content.rstrip(), str(reason)) @@ -1118,7 +1118,7 @@ class _TestQueue(BaseTestCase): def test_no_import_lock_contention(self): with os_helper.temp_cwd(): module_name = 'imported_by_an_imported_module' - with open(module_name + '.py', 'w') as f: + with open(module_name + '.py', 'w', encoding="utf-8") as f: f.write("""if 1: import multiprocessing |