|
1 | 1 | import copy
|
2 | 2 | import ntpath
|
| 3 | +import os |
3 | 4 | import pathlib
|
4 | 5 | import posixpath
|
| 6 | +import shutil |
| 7 | +import subprocess |
| 8 | +import sys |
| 9 | +import sysconfig |
| 10 | +import tempfile |
5 | 11 | import unittest
|
6 | 12 |
|
7 | 13 | from test.support import verbose
|
@@ -864,6 +870,37 @@ def test_PYTHONHOME_in_venv(self):
|
864 | 870 | actual = getpath(ns, expected)
|
865 | 871 | self.assertEqual(expected, actual)
|
866 | 872 |
|
| 873 | + |
| 874 | +class RealGetPathTests(unittest.TestCase): |
| 875 | + @unittest.skipUnless( |
| 876 | + sysconfig.is_python_build(), |
| 877 | + 'Test only available when running from the buildir', |
| 878 | + ) |
| 879 | + @unittest.skipUnless( |
| 880 | + any(sys.platform.startswith(p) for p in ('linux', 'freebsd', 'centos')), |
| 881 | + 'Test only support on Linux-like OS-es (support LD_LIBRARY_PATH)', |
| 882 | + ) |
| 883 | + @unittest.skipUnless( |
| 884 | + sysconfig.get_config_var('LDLIBRARY') != sysconfig.get_config_var('LIBRARY'), |
| 885 | + 'Test only available when using a dynamic libpython', |
| 886 | + ) |
| 887 | + def test_builddir_wrong_library_warning(self): |
| 888 | + library_name = sysconfig.get_config_var('INSTSONAME') |
| 889 | + with tempfile.TemporaryDirectory() as tmpdir: |
| 890 | + shutil.copy2( |
| 891 | + os.path.join(sysconfig.get_config_var('srcdir'), library_name), |
| 892 | + os.path.join(tmpdir, library_name) |
| 893 | + ) |
| 894 | + env = os.environ.copy() |
| 895 | + env['LD_LIBRARY_PATH'] = tmpdir |
| 896 | + process = subprocess.run( |
| 897 | + [sys.executable, '-c', ''], |
| 898 | + env=env, check=True, capture_output=True, text=True, |
| 899 | + ) |
| 900 | + error_msg = 'The runtime library has been loaded from outside the build directory' |
| 901 | + self.assertTrue(process.stderr.startswith(error_msg), process.stderr) |
| 902 | + |
| 903 | + |
867 | 904 | # ******************************************************************************
|
868 | 905 |
|
869 | 906 | DEFAULT_NAMESPACE = dict(
|
|
0 commit comments