10000 GH-107458: fix test_tools refleak by kumaraditya303 · Pull Request #107577 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-107458: fix test_tools refleak #107577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix test_tools refleak
  • Loading branch information
kumaraditya303 committed Aug 3, 2023
commit 2d7a150650c889d90fe7d6cf85b43a9c93a0eccf
24 changes: 7 additions & 17 deletions Lib/test/test_tools/test_sundry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,19 @@

import os
import unittest
from test.support import import_helper

from test.test_tools import scriptsdir, import_tool, skip_if_missing

skip_if_missing()

class TestSundryScripts(unittest.TestCase):
# 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):
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)

def test_sundry(self,):
for fn in os.listdir(scriptsdir):
if not fn.endswith('.py'):
continue
name = fn[:-3]
import_tool(name)


if __name__ == '__main__':
Expand Down
0