|
10 | 10 | import tempfile |
11 | 11 | from unittest import TestCase, skipUnless, skipIf |
12 | 12 | from unittest.mock import patch |
13 | | -from test.support import force_not_colorized, make_clean_env |
| 13 | +from test.support import force_not_colorized, make_clean_env, Py_DEBUG |
14 | 14 | from test.support import SHORT_TIMEOUT, STDLIB_DIR |
15 | 15 | from test.support.import_helper import import_module |
16 | 16 | from test.support.os_helper import EnvironmentVarGuard, unlink |
@@ -1380,3 +1380,16 @@ def test_prompt_after_help(self): |
1380 | 1380 | # Extra stuff (newline and `exit` rewrites) are necessary |
1381 | 1381 | # because of how run_repl works. |
1382 | 1382 | self.assertNotIn(">>> \n>>> >>>", cleaned_output) |
| 1383 | + |
| 1384 | + @skipUnless(Py_DEBUG, '-X showrefcount requires a Python debug build') |
| 1385 | + def test_showrefcount(self): |
| 1386 | + env = os.environ.copy() |
| 1387 | + env.pop("PYTHON_BASIC_REPL", "") |
| 1388 | + output, _ = self.run_repl("1\n1+2\nexit()\n", cmdline_args=['-Xshowrefcount'], env=env) |
| 1389 | + matches = re.findall(r'\[-?\d+ refs, \d+ blocks\]', output) |
| 1390 | + self.assertEqual(len(matches), 3) |
| 1391 | + |
| 1392 | + env["PYTHON_BASIC_REPL"] = "1" |
| 1393 | + output, _ = self.run_repl("1\n1+2\nexit()\n", cmdline_args=['-Xshowrefcount'], env=env) |
| 1394 | + matches = re.findall(r'\[-?\d+ refs, \d+ blocks\]', output) |
| 1395 | + self.assertEqual(len(matches), 3) |
0 commit comments