Skip to content

Commit 19c5ca8

Browse files
committed
pythongh-109615: Fix support test_copy_python_src_ignore()
Fix the test when the test is run on an installed Python: get abs_srcdir of sysconfig, and skip the test if the Python source code cannot be found.
1 parent b1aebf1 commit 19c5ca8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Lib/test/pythoninfo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ def collect_sysconfig(info_add):
520520
'SHELL',
521521
'SOABI',
522522
'abs_builddir',
523+
'abs_srcdir',
523524
'prefix',
524525
'srcdir',
525526
):

Lib/test/test_support.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,13 @@ def test_set_memlimit(self):
802802
support.real_max_memuse = old_real_max_memuse
803803

804804
def test_copy_python_src_ignore(self):
805-
src_dir = sysconfig.get_config_var('srcdir')
805+
src_dir = sysconfig.get_config_var('abs_srcdir')
806+
if not src_dir:
807+
src_dir = sysconfig.get_config_var('srcdir')
806808
src_dir = os.path.abspath(src_dir)
809+
if not os.path.exists(src_dir):
810+
self.skipTest(f"cannot access Python source code directory:"
811+
f" {src_dir!r}")
807812

808813
ignored = {'.git', '__pycache__'}
809814

0 commit comments

Comments
 (0)