GH-107458: fix test_tools refleak (#107577)

This commit is contained in:
Kumar Aditya 2023-08-03 12:06:02 +05:30 committed by GitHub
parent 62a3a15119
commit 46366ca048
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,17 +19,11 @@ class TestSundryScripts(unittest.TestCase):
# 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):
if not fn.endswith('.py'):
continue
name = fn[:-3]
import_tool(name)
finally:
# Unload all modules loaded in this test
import_helper.modules_cleanup(*old_modules)
for fn in os.listdir(scriptsdir):
if not fn.endswith('.py'):
continue
name = fn[:-3]
import_tool(name)
if __name__ == '__main__':