mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-134097: Print number of refs & blocks after each statement in new REPL (gh-134136)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
44b73d3cd4
commit
c31547a591
3 changed files with 24 additions and 1 deletions
|
|
@ -10,7 +10,7 @@
|
|||
import tempfile
|
||||
from unittest import TestCase, skipUnless, skipIf
|
||||
from unittest.mock import patch
|
||||
from test.support import force_not_colorized, make_clean_env
|
||||
from test.support import force_not_colorized, make_clean_env, Py_DEBUG
|
||||
from test.support import SHORT_TIMEOUT, STDLIB_DIR
|
||||
from test.support.import_helper import import_module
|
||||
from test.support.os_helper import EnvironmentVarGuard, unlink
|
||||
|
|
@ -1610,3 +1610,16 @@ def test_prompt_after_help(self):
|
|||
# Extra stuff (newline and `exit` rewrites) are necessary
|
||||
# because of how run_repl works.
|
||||
self.assertNotIn(">>> \n>>> >>>", cleaned_output)
|
||||
|
||||
@skipUnless(Py_DEBUG, '-X showrefcount requires a Python debug build')
|
||||
def test_showrefcount(self):
|
||||
env = os.environ.copy()
|
||||
env.pop("PYTHON_BASIC_REPL", "")
|
||||
output, _ = self.run_repl("1\n1+2\nexit()\n", cmdline_args=['-Xshowrefcount'], env=env)
|
||||
matches = re.findall(r'\[-?\d+ refs, \d+ blocks\]', output)
|
||||
self.assertEqual(len(matches), 3)
|
||||
|
||||
env["PYTHON_BASIC_REPL"] = "1"
|
||||
output, _ = self.run_repl("1\n1+2\nexit()\n", cmdline_args=['-Xshowrefcount'], env=env)
|
||||
matches = re.findall(r'\[-?\d+ refs, \d+ blocks\]', output)
|
||||
self.assertEqual(len(matches), 3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue