bpo-45128: fixes `test_multiprocessing_fork` mysterious crash (GH-28387)

This commit is contained in:
Nikita Sobolev 2021-09-20 01:50:04 +03:00 committed by GitHub
parent e6d05a4092
commit 1d42408495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -0,0 +1,2 @@
Fix ``test_multiprocessing_fork`` failure due to ``test_logging`` and
``sys.modules`` manipulation.