Skip to content
Closed
Changes from all commits
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
12 changes: 12 additions & 0 deletions Lib/test/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,5 +881,17 @@ 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
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.

Copy link
Contributor Author

@LamentXU123 LamentXU123 Oct 12, 2025

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
)
self.assertTrue(output.returncode == 0)
self.assertTrue(output.stdout.startswith("Platform: "))
Copy link
Contributor

Choose a reason for hiding this comment

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

The docs say that all these values should be present in the text, could we check for them in the test? That way the test validates they're there (and if the output changes, know it needs to change)

get_platform(), get_python_version(), get_path() and get_config_vars().

Copy link
Contributor Author

@LamentXU123 LamentXU123 Oct 12, 2025

Choose a reason for hiding this comment

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

I will add a stricter test case by mocking an output and directly compare the mock output and the real one.



if __name__ == "__main__":
unittest.main()
Loading