Skip to content

Commit e9b4131

Browse files
committed
Add test_bad_argv0_posix
Signed-off-by: Filipe Laíns <lains@riseup.net>
1 parent 74c5658 commit e9b4131

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Lib/test/test_getpath.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,34 @@ def test_symlink_normal_posix(self):
497497
actual = getpath(ns, expected)
498498
self.assertEqual(expected, actual)
499499

500+
def test_bad_argv0_posix(self):
501+
"""Test that executable resolves correctly if argv0 is not Python and we
502+
know real_executable (getpath.c computes it from readlink(/proc/self/exe)).
503+
"""
504+
ns = MockPosixNamespace(
505+
PREFIX="/usr",
506+
argv0="not-python",
507+
real_executable="/usr/bin/python",
508+
)
509+
ns.add_known_xfile("/usr/bin/python")
510+
ns.add_known_file("/usr/lib/python9.8/os.py")
511+
ns.add_known_dir("/usr/lib/python9.8/lib-dynload")
512+
expected = dict(
513+
executable="/usr/bin/python",
514+
base_executable="/usr/bin/python",
515+
prefix="/usr",
516+
exec_prefix="/usr",
517+
module_search_paths_set=1,
518+
module_search_paths=[
519+
"/usr/lib/python98.zip",
520+
"/usr/lib/python9.8",
521+
"/usr/lib/python9.8/lib-dynload",
522+
],
523+
)
524+
actual = getpath(ns, expected)
525+
self.assertEqual(expected, actual)
526+
527+
500528
def test_symlink_buildpath_posix(self):
501529
"""Test an in-build-tree layout on POSIX.
502530

0 commit comments

Comments
 (0)