diff options
author | Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> | 2022-09-15 17:31:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-15 17:31:45 (GMT) |
commit | 303bd880475b510481d86a8c48b62d21d0e3bb53 (patch) | |
tree | c70cf385615eff683da3a4e966f00d0c77a9c4f9 /Lib | |
parent | a41ed975e863ae0ca435783596f14f8492d62f8d (diff) | |
download | cpython-303bd880475b510481d86a8c48b62d21d0e3bb53.zip cpython-303bd880475b510481d86a8c48b62d21d0e3bb53.tar.gz cpython-303bd880475b510481d86a8c48b62d21d0e3bb53.tar.bz2 |
Fix ResourceWarning in test.test_frame (GH-96831)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_frame.py | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/Lib/test/test_frame.py b/Lib/test/test_frame.py index 9fab176..5dda2fb 100644 --- a/Lib/test/test_frame.py +++ b/Lib/test/test_frame.py @@ -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): @@ -238,25 +240,26 @@ class ReprTest(unittest.TestCase): 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() |