Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update test files from CPython v3.12.0 #5127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
06bb68a
Update test_cmd_line.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
999dcbd
Edit test_cmd_line.py
NakanoMiku39 Nov 30, 2023
700f2b9
Update test_cmd_line_script.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
9a61716
Edit test_cmd_line_script.py
NakanoMiku39 Nov 30, 2023
c28cca9
Update test_code_module.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
c5364ca
Update test_compare.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
fa3eae6
Update test_complex.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
07f013d
Edit test_complex.py
NakanoMiku39 Nov 30, 2023
b93199f
Update test_context.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
5c6b4cb
Update test_decorators.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
926c4ce
Update test_defaultdict.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
b05d592
Update test_descr.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
b11d554
Edit test_descr.py
NakanoMiku39 Nov 30, 2023
c4e2d6e
Add test_descrtut.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
f1991c2
Edit test_descrtut.py
NakanoMiku39 Nov 30, 2023
d5e4af7
Update test_dict.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
43ede61
Update test_dictviews.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
186eac5
Update test_dtrace.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
f7c7398
Update test_dynamic.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
1d76b76
Update test_eintr.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
ad3f0ae
Update test_eof.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
3945e9a
Update test_epoll.py from CPython v3.12.0
NakanoMiku39 Nov 30, 2023
784b5f1
Edit test_dictviews
NakanoMiku39 Nov 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Lib/test/test_cmd_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
if not support.has_subprocess_support:
raise unittest.SkipTest("test module requires subprocess")

# Debug build?
Py_DEBUG = hasattr(sys, "gettotalrefcount")


# XXX (ncoghlan): Move to script_helper and make consistent with run_python
def _kill_python_and_exit_code(p):
Expand Down Expand Up @@ -144,7 +141,7 @@ def run_python(*args):
# "-X showrefcount" shows the refcount, but only in debug builds
rc, out, err = run_python('-I', '-X', 'showrefcount', '-c', code)
self.assertEqual(out.rstrip(), b"{'showrefcount': True}")
if Py_DEBUG:
if support.Py_DEBUG:
# bpo-46417: Tolerate negative reference count which can occur
# because of bugs in C extensions. This test is only about checking
# the showrefcount feature.
Expand Down Expand Up @@ -753,7 +750,7 @@ def test_xdev(self):
code = ("import warnings; "
"print(' '.join('%s::%s' % (f[0], f[2].__name__) "
"for f in warnings.filters))")
if Py_DEBUG:
if support.Py_DEBUG:
expected_filters = "default::Warning"
else:
expected_filters = ("default::Warning "
Expand Down Expand Up @@ -827,7 +824,7 @@ def test_warnings_filter_precedence(self):
expected_filters = ("error::BytesWarning "
"once::UserWarning "
"always::UserWarning")
if not Py_DEBUG:
if not support.Py_DEBUG:
expected_filters += (" "
"default::DeprecationWarning "
"ignore::DeprecationWarning "
Expand Down Expand Up @@ -867,10 +864,10 @@ def test_pythonmalloc(self):
# Test the PYTHONMALLOC environment variable
pymalloc = support.with_pymalloc()
if pymalloc:
default_name = 'pymalloc_debug' if Py_DEBUG else 'pymalloc'
default_name = 'pymalloc_debug' if support.Py_DEBUG else 'pymalloc'
default_name_debug = 'pymalloc_debug'
else:
default_name = 'malloc_debug' if Py_DEBUG else 'malloc'
default_name = 'malloc_debug' if support.Py_DEBUG else 'malloc'
default_name_debug = 'malloc_debug'

tests = [
Expand Down Expand Up @@ -933,6 +930,8 @@ def test_parsing_error(self):
self.assertTrue(proc.stderr.startswith(err_msg), proc.stderr)
self.assertNotEqual(proc.returncode, 0)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_int_max_str_digits(self):
code = "import sys; print(sys.flags.int_max_str_digits, sys.get_int_max_str_digits())"

Expand All @@ -950,7 +949,8 @@ def res2int(res):
return tuple(int(i) for i in out.split())

res = assert_python_ok('-c', code)
self.assertEqual(res2int(res), (-1, sys.get_int_max_str_digits()))
current_max = sys.get_int_max_str_digits()
self.assertEqual(res2int(res), (current_max, current_max))
res = assert_python_ok('-X', 'int_max_str_digits=0', '-c', code)
self.assertEqual(res2int(res), (0, 0))
res = assert_python_ok('-X', 'int_max_str_digits=4000', '-c', code)
Expand Down
37 changes: 33 additions & 4 deletions Lib/test/test_cmd_line_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,9 +662,9 @@ def test_syntaxerror_multi_line_fstring(self):
self.assertEqual(
stderr.splitlines()[-3:],
[
b' foo"""',
b' ^',
b'SyntaxError: f-string: empty expression not allowed',
b' foo = f"""{}',
b' ^',
b'SyntaxError: f-string: valid expression required before \'}\'',
],
)

Expand All @@ -685,6 +685,35 @@ def test_syntaxerror_invalid_escape_sequence_multi_line(self):
],
)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_syntaxerror_null_bytes(self):
script = "x = '\0' nothing to see here\n';import os;os.system('echo pwnd')\n"
with os_helper.temp_dir() as script_dir:
script_name = _make_test_script(script_dir, 'script', script)
exitcode, stdout, stderr = assert_python_failure(script_name)
self.assertEqual(
stderr.splitlines()[-2:],
[ b" x = '",
b'SyntaxError: source code cannot contain null bytes'
],
)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_syntaxerror_null_bytes_in_multiline_string(self):
scripts = ["\n'''\nmultilinestring\0\n'''", "\nf'''\nmultilinestring\0\n'''"] # Both normal and f-strings
with os_helper.temp_dir() as script_dir:
for script in scripts:
script_name = _make_test_script(script_dir, 'script', script)
_, _, stderr = assert_python_failure(script_name)
self.assertEqual(
stderr.splitlines()[-2:],
[ b" multilinestring",
b'SyntaxError: source code cannot contain null bytes'
]
)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_consistent_sys_path_for_direct_execution(self):
Expand Down Expand Up @@ -785,7 +814,7 @@ def test_script_as_dev_fd(self):
with os_helper.temp_dir() as work_dir:
script_name = _make_test_script(work_dir, 'script.py', script)
with open(script_name, "r") as fp:
p = spawn_python(f"/dev/fd/{fp.fileno()}", close_fds=False, pass_fds=(0,1,2,fp.fileno()))
p = spawn_python(f"/dev/fd/{fp.fileno()}", close_fds=True, pass_fds=(0,1,2,fp.fileno()))
out, err = p.communicate()
self.assertEqual(out, b"12345678912345678912345\n")

Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_code_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from unittest import mock
from test.support import import_helper


code = import_helper.import_module('code')


Expand Down
Loading