From a8c8526fd8ce2f3f50837bbbb820741e54b58512 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 12 Oct 2022 17:26:21 +0200 Subject: gh-97669: Fix test_tools reference leak (#98216) test_tools.test_sundry() now uses an unittest mock to prevent the logging module to register a real "atfork" function which kept the logging module dictionary alive. So the logging module can be properly unloaded. Previously, the logging module was loaded before test_sundry(), but it's no longer the case since recent test_tools sub-tests removals. --- Lib/test/test_tools/test_sundry.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Lib/test/test_tools/test_sundry.py') diff --git a/Lib/test/test_tools/test_sundry.py b/Lib/test/test_tools/test_sundry.py index 04e38acdb34..81f06763980 100644 --- a/Lib/test/test_tools/test_sundry.py +++ b/Lib/test/test_tools/test_sundry.py @@ -27,7 +27,11 @@ class TestSundryScripts(unittest.TestCase): skiplist = denylist + allowlist + other - def test_sundry(self): + # import logging registers "atfork" functions which keep indirectly the + # logging module dictionary alive. Mock the function to be able to unload + # cleanly the logging module. + @import_helper.mock_register_at_fork + def test_sundry(self, mock_os): old_modules = import_helper.modules_setup() try: for fn in os.listdir(scriptsdir): -- cgit v1.2.3