diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2021-09-19 22:50:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-19 22:50:04 (GMT) |
commit | 1d42408495402b06ecae91420735aeff454be6b5 (patch) | |
tree | e4237742eb668e6c26fc499a0b0ec673e7d7f475 | |
parent | e6d05a4092b4176a30d1d1596585df13c2ab676d (diff) | |
download | cpython-1d42408495402b06ecae91420735aeff454be6b5.zip cpython-1d42408495402b06ecae91420735aeff454be6b5.tar.gz cpython-1d42408495402b06ecae91420735aeff454be6b5.tar.bz2 |
bpo-45128: fixes `test_multiprocessing_fork` mysterious crash (GH-28387)
-rw-r--r-- | Lib/test/test_logging.py | 7 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Tests/2021-09-16-17-22-35.bpo-45128.Jz6fl2.rst | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 211fe4b..7a80244 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -4437,8 +4437,10 @@ class LogRecordTest(BaseTest): name = mp.current_process().name r1 = logging.makeLogRecord({'msg': f'msg1_{key}'}) - del sys.modules['multiprocessing'] - r2 = logging.makeLogRecord({'msg': f'msg2_{key}'}) + + # https://bugs.python.org/issue45128 + with support.swap_item(sys.modules, 'multiprocessing', None): + r2 = logging.makeLogRecord({'msg': f'msg2_{key}'}) results = {'processName' : name, 'r1.processName': r1.processName, @@ -4487,7 +4489,6 @@ class LogRecordTest(BaseTest): if multiprocessing_imported: import multiprocessing - def test_optional(self): r = logging.makeLogRecord({}) NOT_NONE = self.assertIsNotNone diff --git a/Misc/NEWS.d/next/Tests/2021-09-16-17-22-35.bpo-45128.Jz6fl2.rst b/Misc/NEWS.d/next/Tests/2021-09-16-17-22-35.bpo-45128.Jz6fl2.rst new file mode 100644 index 0000000..b50eb32 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2021-09-16-17-22-35.bpo-45128.Jz6fl2.rst @@ -0,0 +1,2 @@ +Fix ``test_multiprocessing_fork`` failure due to ``test_logging`` and +``sys.modules`` manipulation. |