MCPcopy Index your code
hub / github.com/python/cpython / test_no_memory

Method test_no_memory

Lib/test/test_repl.py:92–111  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

90 # _PyRefchain_Trace() on memory allocation error.
91 @unittest.skipIf(support.Py_TRACE_REFS, 'cannot test Py_TRACE_REFS build')
92 def test_no_memory(self):
93 import_module("_testcapi")
94 # Issue #30696: Fix the interactive interpreter looping endlessly when
95 # no memory. Check also that the fix does not break the interactive
96 # loop when an exception is raised.
97 user_input = """
98 import sys, _testcapi
99 1/0
100 print('After the exception.')
101 _testcapi.set_nomemory(0)
102 sys.exit(0)
103 """
104 user_input = dedent(user_input)
105 p = spawn_repl()
106 with SuppressCrashReport():
107 p.stdin.write(user_input)
108 output = kill_python(p)
109 self.assertIn('After the exception.', output)
110 # Exit code 120: Py_FinalizeEx() failed to flush stdout and stderr.
111 self.assertIn(p.returncode, (1, 120))
112
113 @cpython_only
114 def test_multiline_string_parsing(self):

Callers

nothing calls this directly

Calls 7

import_moduleFunction · 0.90
dedentFunction · 0.90
SuppressCrashReportClass · 0.90
kill_pythonFunction · 0.90
spawn_replFunction · 0.85
assertInMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected