summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2021-12-11 13:43:40 +0000
committerGitHub <noreply@github.com>2021-12-11 13:43:40 +0000
commit971ece8e1738b1107dda692cc44c6d8ddce384cd (patch)
tree13cb2af42b9c86d0131767ed0d176059de319a38 /Lib
parent4fe5585240f64c3d14eb635ff82b163f92074b3a (diff)
downloadcpython-git-971ece8e1738b1107dda692cc44c6d8ddce384cd.tar.gz
bpo-46048: Fix parsing of single character lines in getpath readlines() (GH-30048)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_site.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 76d35daed0..199022a105 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -594,6 +594,26 @@ class _pthFileTests(unittest.TestCase):
sys_path.append(abs_path)
return sys_path
+ def test_underpth_basic(self):
+ libpath = test.support.STDLIB_DIR
+ exe_prefix = os.path.dirname(sys.executable)
+ pth_lines = ['#.', '# ..', *sys.path, '.', '..']
+ exe_file = self._create_underpth_exe(pth_lines)
+ sys_path = self._calc_sys_path_for_underpth_nosite(
+ os.path.dirname(exe_file),
+ pth_lines)
+
+ output = subprocess.check_output([exe_file, '-c',
+ 'import sys; print("\\n".join(sys.path) if sys.flags.no_site else "")'
+ ], encoding='ansi')
+ actual_sys_path = output.rstrip().split('\n')
+ self.assertTrue(actual_sys_path, "sys.flags.no_site was False")
+ self.assertEqual(
+ actual_sys_path,
+ sys_path,
+ "sys.path is incorrect"
+ )
+
def test_underpth_nosite_file(self):
libpath = test.support.STDLIB_DIR
exe_prefix = os.path.dirname(sys.executable)