Fix ResourceWarning in test.test_frame (GH-96831)
This commit is contained in:
parent
a41ed975e8
commit
303bd88047
@ -1,10 +1,12 @@
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import textwrap
|
||||||
import types
|
import types
|
||||||
import unittest
|
import unittest
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
from test import support
|
from test import support
|
||||||
|
from test.support.script_helper import assert_python_ok
|
||||||
|
|
||||||
|
|
||||||
class ClearTest(unittest.TestCase):
|
class ClearTest(unittest.TestCase):
|
||||||
@ -238,25 +240,26 @@ class ReprTest(unittest.TestCase):
|
|||||||
class TestIncompleteFrameAreInvisible(unittest.TestCase):
|
class TestIncompleteFrameAreInvisible(unittest.TestCase):
|
||||||
|
|
||||||
def test_issue95818(self):
|
def test_issue95818(self):
|
||||||
#See GH-95818 for details
|
# See GH-95818 for details
|
||||||
import gc
|
code = textwrap.dedent(f"""
|
||||||
self.addCleanup(gc.set_threshold, *gc.get_threshold())
|
import gc
|
||||||
|
|
||||||
gc.set_threshold(1,1,1)
|
gc.set_threshold(1,1,1)
|
||||||
class GCHello:
|
class GCHello:
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
print("Destroyed from gc")
|
print("Destroyed from gc")
|
||||||
|
|
||||||
def gen():
|
def gen():
|
||||||
yield
|
yield
|
||||||
|
|
||||||
fd = open(__file__)
|
|
||||||
l = [fd, GCHello()]
|
|
||||||
l.append(l)
|
|
||||||
del fd
|
|
||||||
del l
|
|
||||||
gen()
|
|
||||||
|
|
||||||
|
fd = open({__file__!r})
|
||||||
|
l = [fd, GCHello()]
|
||||||
|
l.append(l)
|
||||||
|
del fd
|
||||||
|
del l
|
||||||
|
gen()
|
||||||
|
""")
|
||||||
|
assert_python_ok("-c", code)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user