From 5fcc7935b7ade88c15d74054cb66fbc065d4d3ef Mon Sep 17 00:00:00 2001 From: Weilin Du <108666168+LamentXU123@users.noreply.github.com> Date: Sat, 11 Oct 2025 12:51:05 +0800 Subject: [PATCH 1/6] Update test_sysconfig.py --- Lib/test/test_sysconfig.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 8101657b04a5c6..18ce87027b649b 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -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 @@ -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', @@ -783,7 +782,6 @@ def test_parse_makefile(self): 'var8': '$(var3)', 'var9': '$(var3)', 'var10': '$', - 'var11': '${ORIGIN}dollar$5', }) def _test_parse_makefile_recursion(self): @@ -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( + [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() From 663642c754d0cc63eaf623a6421bdb42604e43ea Mon Sep 17 00:00:00 2001 From: Weilin Du <108666168+LamentXU123@users.noreply.github.com> Date: Sat, 11 Oct 2025 13:00:12 +0800 Subject: [PATCH 2/6] Update test_sysconfig.py --- Lib/test/test_sysconfig.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 18ce87027b649b..75e6b08c276e7f 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -878,6 +878,7 @@ 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( @@ -900,5 +901,7 @@ def test_config_output(self): Variables: {vars}''' self.assertTrue(output.stdout == mock_result) + + if __name__ == "__main__": unittest.main() From 9a011678025dedb8806865f7b577b08d2392423c Mon Sep 17 00:00:00 2001 From: Weilin Du <108666168+LamentXU123@users.noreply.github.com> Date: Sat, 11 Oct 2025 13:02:09 +0800 Subject: [PATCH 3/6] Update test_sysconfig.py --- Lib/test/test_sysconfig.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 75e6b08c276e7f..cf3af2c1295eff 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -770,6 +770,7 @@ 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', @@ -782,6 +783,7 @@ def test_parse_makefile(self): 'var8': '$(var3)', 'var9': '$(var3)', 'var10': '$', + 'var11': '${ORIGIN}dollar$5', }) def _test_parse_makefile_recursion(self): From 85d0bc45bcecd386a294283789b2771d1b426e5a Mon Sep 17 00:00:00 2001 From: Weilin Du <108666168+LamentXU123@users.noreply.github.com> Date: Sat, 11 Oct 2025 13:14:27 +0800 Subject: [PATCH 4/6] Fix lint CI --- Lib/test/test_sysconfig.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index cf3af2c1295eff..4208fe84440b10 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -889,7 +889,7 @@ def test_config_output(self): text=True, check=True ) - paths, vars = '', '' + paths, vars = 'Paths: \n', 'Variables: \n' for key, value in sorted(get_paths().items()): paths += f'\t{key} = "{value}"\n' for key, value in sorted(get_config_vars().items()): @@ -898,9 +898,7 @@ def test_config_output(self): Python version: "{get_python_version()}" Current installation scheme: "{get_default_scheme()}" -Paths: {paths} -Variables: {vars}''' self.assertTrue(output.stdout == mock_result) From ba7362dcfdaefc62d0ffe566dd68c7c36d11e9c3 Mon Sep 17 00:00:00 2001 From: Weilin Du <108666168+LamentXU123@users.noreply.github.com> Date: Sat, 11 Oct 2025 14:16:11 +0800 Subject: [PATCH 5/6] fix CI --- Lib/test/test_sysconfig.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 4208fe84440b10..77eba7a5d36e5d 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -889,18 +889,8 @@ def test_config_output(self): text=True, check=True ) - paths, vars = 'Paths: \n', 'Variables: \n' - 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} -{vars}''' - self.assertTrue(output.stdout == mock_result) + self.assertTrue(output.returncode == 0) + self.assertTrue(output.stdout.startswith("Platform: ")) if __name__ == "__main__": From fd39af031acdbb7b75d79ed009ebfab9eebc9f75 Mon Sep 17 00:00:00 2001 From: Weilin Du <108666168+LamentXU123@users.noreply.github.com> Date: Sat, 11 Oct 2025 14:18:25 +0800 Subject: [PATCH 6/6] fix lint --- Lib/test/test_sysconfig.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 77eba7a5d36e5d..39bd0fac7dbf51 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -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, get_python_version, + _expand_vars, _get_preferred_schemes, is_python_build, _PROJECT_BASE) from sysconfig.__main__ import _main, _parse_makefile, _get_pybuilddir, _get_json_data_name import _imp