Skip to content
Closed
Changes from 1 commit
Commits
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
Next Next commit
Update test_sysconfig.py
  • Loading branch information
LamentXU123 authored Oct 11, 2025
commit 5fcc7935b7ade88c15d74054cb66fbc065d4d3ef
27 changes: 23 additions & 4 deletions Lib/test/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from sysconfig import (get_paths, get_platform, get_config_vars,
get_path, get_path_names, _INSTALL_SCHEMES,
get_default_scheme, get_scheme_names, get_config_var,
_expand_vars, _get_preferred_schemes,
_expand_vars, _get_preferred_schemes, get_python_version,
is_python_build, _PROJECT_BASE)
from sysconfig.__main__ import _main, _parse_makefile, _get_pybuilddir, _get_json_data_name
import _imp
Expand Down Expand Up @@ -770,7 +770,6 @@ def test_parse_makefile(self):
print("var8=$$(var3)", file=makefile)
print("var9=$(var10)(var3)", file=makefile)
print("var10=$$", file=makefile)
print("var11=$${ORIGIN}${var5}", file=makefile)
vars = _parse_makefile(TESTFN)
self.assertEqual(vars, {
'var1': 'ab42',
Expand All @@ -783,7 +782,6 @@ def test_parse_makefile(self):
'var8': '$(var3)',
'var9': '$(var3)',
'var10': '$',
'var11': '${ORIGIN}dollar$5',
})

def _test_parse_makefile_recursion(self):
Expand Down Expand Up @@ -880,6 +878,27 @@ def test_is_python_build_check_home(self):
):
sysconfig.is_python_build('foo')


class CommandLineTests(unittest.TestCase):
def test_config_output(self):
output = subprocess.run(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see in the base issue the pattern for these tests is to use contextlib.redirect_stdout + call the function which implements main directly (sysconfig._main) rather than run / use a subprocess.

See for example: https://github.com/python/cpython/pull/131275/files#diff-eabc91c9e7a2586ffc6ca849d6636e74e28825a4515745c280b045dbdf857e39R723-R727

That should also fix the WASI check which is currently failing with: OSError: [Errno 58] wasi does not support processes.

@LamentXU123 LamentXU123 Oct 12, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! Thank you. I am really stuck on how to fix the WASI test.

[sys.executable, "-m", "sysconfig"],
capture_output=True,
text=True,
check=True
)
paths, vars = '', ''
for key, value in sorted(get_paths().items()):
paths += f'\t{key} = "{value}"\n'
for key, value in sorted(get_config_vars().items()):
vars += f'\t{key} = "{value}"\n'
mock_result = f'''Platform: "{get_platform()}"
Python version: "{get_python_version()}"
Current installation scheme: "{get_default_scheme()}"

Paths:
{paths}
Variables:
{vars}'''
self.assertTrue(output.stdout == mock_result)
if __name__ == "__main__":
unittest.main()