Skip to content

Commit 39874b5

Browse files
committed
gh-157242: Use support.inject_memory_error_cm() in test_dict
1 parent ddc647a commit 39874b5

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

‎Lib/test/test_dict.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,16 @@ def test_item_iterator_oom(self):
121121
import_helper.import_module('_testcapi')
122122
from test.support.script_helper import assert_python_ok
123123
code = """if 1:
124-
import _testcapi
124+
from test import support
125125
items = {1: 2, 3: 4}.items()
126126
ballast = [(i, i) for i in range(3000)]
127127
held = []
128128
for start in range(1, 5):
129-
_testcapi.set_nomemory(start)
130129
try:
131-
held.append(iter(items))
130+
with support.inject_memory_error_cm(start):
131+
held.append(iter(items))
132132
except MemoryError:
133133
pass
134-
finally:
135-
_testcapi.remove_mem_hooks()
136134
"""
137135
assert_python_ok('-c', code)
138136

0 commit comments

Comments
 (0)