diff options
author | Victor Stinner <vstinner@python.org> | 2023-09-27 08:18:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-27 08:18:39 (GMT) |
commit | 1512d6c6ee2a770afb339bbb74c1b990116f7f89 (patch) | |
tree | c06112bc117488f73830e3f739a522020eec8fea /Lib/test/test_support.py | |
parent | 0e28d0f7a1bc3776cc07e0f8b91bc43fcdbb4206 (diff) | |
download | cpython-1512d6c6ee2a770afb339bbb74c1b990116f7f89.zip cpython-1512d6c6ee2a770afb339bbb74c1b990116f7f89.tar.gz cpython-1512d6c6ee2a770afb339bbb74c1b990116f7f89.tar.bz2 |
gh-109615: Fix test_tools.test_freeze SRCDIR (#109935)
Fix copy_source_tree() function of test_tools.test_freeze:
* Don't copy SRC_DIR/build/ anymore. This directory is modified by
other tests running in parallel.
* Add test.support.copy_python_src_ignore().
* Use sysconfig to get the source directory.
* Use sysconfig.get_config_var() to get CONFIG_ARGS variable.
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r-- | Lib/test/test_support.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 5b57c5f..af38db5 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -7,6 +7,7 @@ import socket import stat import subprocess import sys +import sysconfig import tempfile import textwrap import unittest @@ -800,6 +801,27 @@ class TestSupport(unittest.TestCase): support.max_memuse = old_max_memuse support.real_max_memuse = old_real_max_memuse + def test_copy_python_src_ignore(self): + src_dir = sysconfig.get_config_var('srcdir') + src_dir = os.path.abspath(src_dir) + + ignored = {'.git', '__pycache__'} + + # Source code directory + names = os.listdir(src_dir) + self.assertEqual(support.copy_python_src_ignore(src_dir, names), + ignored | {'build'}) + + # Doc/ directory + path = os.path.join(src_dir, 'Doc') + self.assertEqual(support.copy_python_src_ignore(path, os.listdir(path)), + ignored | {'build', 'venv'}) + + # An other directory + path = os.path.join(src_dir, 'Objects') + self.assertEqual(support.copy_python_src_ignore(path, os.listdir(path)), + ignored) + # XXX -follows a list of untested API # make_legacy_pyc # is_resource_enabled |