Skip to content

Commit 06bb68a

Browse files
committed
Update test_cmd_line.py from CPython v3.12.0
1 parent 460e983 commit 06bb68a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Lib/test/test_cmd_line.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
if not support.has_subprocess_support:
1919
raise unittest.SkipTest("test module requires subprocess")
2020

21-
# Debug build?
22-
Py_DEBUG = hasattr(sys, "gettotalrefcount")
23-
2421

2522
# XXX (ncoghlan): Move to script_helper and make consistent with run_python
2623
def _kill_python_and_exit_code(p):
@@ -144,7 +141,7 @@ def run_python(*args):
144141
# "-X showrefcount" shows the refcount, but only in debug builds
145142
rc, out, err = run_python('-I', '-X', 'showrefcount', '-c', code)
146143
self.assertEqual(out.rstrip(), b"{'showrefcount': True}")
147-
if Py_DEBUG:
144+
if support.Py_DEBUG:
148145
# bpo-46417: Tolerate negative reference count which can occur
149146
# because of bugs in C extensions. This test is only about checking
150147
# the showrefcount feature.
@@ -753,7 +750,7 @@ def test_xdev(self):
753750
code = ("import warnings; "
754751
"print(' '.join('%s::%s' % (f[0], f[2].__name__) "
755752
"for f in warnings.filters))")
756-
if Py_DEBUG:
753+
if support.Py_DEBUG:
757754
expected_filters = "default::Warning"
758755
else:
759756
expected_filters = ("default::Warning "
@@ -827,7 +824,7 @@ def test_warnings_filter_precedence(self):
827824
expected_filters = ("error::BytesWarning "
828825
"once::UserWarning "
829826
"always::UserWarning")
830-
if not Py_DEBUG:
827+
if not support.Py_DEBUG:
831828
expected_filters += (" "
832829
"default::DeprecationWarning "
833830
"ignore::DeprecationWarning "
@@ -867,10 +864,10 @@ def test_pythonmalloc(self):
867864
# Test the PYTHONMALLOC environment variable
868865
pymalloc = support.with_pymalloc()
869866
if pymalloc:
870-
default_name = 'pymalloc_debug' if Py_DEBUG else 'pymalloc'
867+
default_name = 'pymalloc_debug' if support.Py_DEBUG else 'pymalloc'
871868
default_name_debug = 'pymalloc_debug'
872869
else:
873-
default_name = 'malloc_debug' if Py_DEBUG else 'malloc'
870+
default_name = 'malloc_debug' if support.Py_DEBUG else 'malloc'
874871
default_name_debug = 'malloc_debug'
875872

876873
tests = [
@@ -950,7 +947,8 @@ def res2int(res):
950947
return tuple(int(i) for i in out.split())
951948

952949
res = assert_python_ok('-c', code)
953-
self.assertEqual(res2int(res), (-1, sys.get_int_max_str_digits()))
950+
current_max = sys.get_int_max_str_digits()
951+
self.assertEqual(res2int(res), (current_max, current_max))
954952
res = assert_python_ok('-X', 'int_max_str_digits=0', '-c', code)
955953
self.assertEqual(res2int(res), (0, 0))
956954
res = assert_python_ok('-X', 'int_max_str_digits=4000', '-c', code)

0 commit comments

Comments
 (0)