Skip to content

gh-96696: Fix ResourceWarning in test.test_frame #96831

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 1 commit into from
Sep 15, 2022
Merged
Changes from all commits
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
35 changes: 19 additions & 16 deletions Lib/test/test_frame.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import re
import sys
import textwrap
import types
import unittest
import weakref

from test import support
from test.support.script_helper import assert_python_ok


class ClearTest(unittest.TestCase):
Expand Down Expand Up @@ -238,25 +240,26 @@ def inner():
class TestIncompleteFrameAreInvisible(unittest.TestCase):

def test_issue95818(self):
#See GH-95818 for details
import gc
self.addCleanup(gc.set_threshold, *gc.get_threshold())
# See GH-95818 for details
code = textwrap.dedent(f"""
import gc

gc.set_threshold(1,1,1)
class GCHello:
def __del__(self):
print("Destroyed from gc")
gc.set_threshold(1,1,1)
class GCHello:
def __del__(self):
print("Destroyed from gc")

def gen():
yield

fd = open(__file__)
l = [fd, GCHello()]
l.append(l)
del fd
del l
gen()
def gen():
yield

fd = open({__file__!r})
l = [fd, GCHello()]
l.append(l)
del fd
del l
gen()
""")
assert_python_ok("-c", code)

if __name__ == "__main__":
unittest.main()