Skip to content

Commit 7bb0e9f

Browse files
committed
Add test
Signed-off-by: Filipe Laíns <lains@riseup.net
1 parent bf40c17 commit 7bb0e9f

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lib/test/test_getpath.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import copy
22
import ntpath
3+
import os
34
import pathlib
45
import posixpath
6+
import shutil
7+
import subprocess
8+
import sys
9+
import sysconfig
10+
import tempfile
511
import unittest
612

713
from test.support import verbose
@@ -864,6 +870,30 @@ def test_PYTHONHOME_in_venv(self):
864870
actual = getpath(ns, expected)
865871
self.assertEqual(expected, actual)
866872

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(os.name == 'posix', 'Test only support on POSIX')
880+
def test_builddir_wrong_library_warning(self):
881+
library_name = sysconfig.get_config_var('INSTSONAME')
882+
with tempfile.TemporaryDirectory() as tmpdir:
883+
shutil.copy2(
884+
os.path.join(sysconfig.get_config_var('srcdir'), library_name),
885+
os.path.join(tmpdir, library_name)
886+
)
887+
env = os.environ.copy()
888+
env['LD_LIBRARY_PATH'] = tmpdir
889+
process = subprocess.run(
890+
[sys.executable, '-c', ''],
891+
env=env, check=True, capture_output=True, text=True,
892+
)
893+
error_msg = 'The runtime library has been loaded from outside the build directory'
894+
self.assertTrue(process.stderr.startswith(error_msg))
895+
896+
867897
# ******************************************************************************
868898

869899
DEFAULT_NAMESPACE = dict(

0 commit comments

Comments
 (0)