mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-124722: Fix leak in test_detach_materialized_dict_no_memory
(GH-124769)
This commit is contained in:
parent
b5774603a0
commit
6f4d64b048
1 changed files with 30 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
||||||
"Test the functionality of Python classes implementing operators."
|
"Test the functionality of Python classes implementing operators."
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import test.support
|
from test.support import cpython_only, import_helper, script_helper
|
||||||
|
|
||||||
testmeths = [
|
testmeths = [
|
||||||
|
|
||||||
|
@ -933,8 +933,15 @@ class TestInlineValues(unittest.TestCase):
|
||||||
C.a = X()
|
C.a = X()
|
||||||
C.a = X()
|
C.a = X()
|
||||||
|
|
||||||
|
@cpython_only
|
||||||
def test_detach_materialized_dict_no_memory(self):
|
def test_detach_materialized_dict_no_memory(self):
|
||||||
|
# Skip test if _testcapi is not available:
|
||||||
|
import_helper.import_module('_testcapi')
|
||||||
|
|
||||||
|
code = """if 1:
|
||||||
|
import test.support
|
||||||
import _testcapi
|
import _testcapi
|
||||||
|
|
||||||
class A:
|
class A:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.a = 1
|
self.a = 1
|
||||||
|
@ -944,9 +951,18 @@ class TestInlineValues(unittest.TestCase):
|
||||||
with test.support.catch_unraisable_exception() as ex:
|
with test.support.catch_unraisable_exception() as ex:
|
||||||
_testcapi.set_nomemory(0, 1)
|
_testcapi.set_nomemory(0, 1)
|
||||||
del a
|
del a
|
||||||
self.assertEqual(ex.unraisable.exc_type, MemoryError)
|
assert ex.unraisable.exc_type is MemoryError
|
||||||
with self.assertRaises(KeyError):
|
try:
|
||||||
d["a"]
|
d["a"]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
assert False, "KeyError not raised"
|
||||||
|
"""
|
||||||
|
rc, out, err = script_helper.assert_python_ok("-c", code)
|
||||||
|
self.assertEqual(rc, 0)
|
||||||
|
self.assertFalse(out, msg=out.decode('utf-8'))
|
||||||
|
self.assertFalse(err, msg=err.decode('utf-8'))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue