Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Lib/test/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@ def test_user_similar(self):
base = base.replace(sys.base_prefix, sys.prefix)
if HAS_USER_BASE:
user_path = get_path(name, 'posix_user')
self.assertEqual(user_path, global_path.replace(base, user, 1))
expected = global_path.replace(base, user, 1)
# bpo-44860: platlib of posix_user doesn't use sys.platlibdir
if name == 'platlib' and sys.platlibdir != 'lib':

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this? The replacement can always happen.

Suggested change
if name == 'platlib' and sys.platlibdir != 'lib':
if name == 'platlib':

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str.replace() is not reliabe, the full path may contain the /lib/ substring multiple times. Like /tmp/lib/runtests/lib/python3.9/. I prefer to only use it if it's really needed :-p

Or maybe we should use a more reliable replacement, like a regex?

expected = expected.replace(f'/{sys.platlibdir}/', '/lib/')
self.assertEqual(user_path, expected)

def test_main(self):
# just making sure _main() runs and returns things in the stdout
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Update ``test_sysconfig.test_user_similar()`` for the posix_user scheme:
``platlib`` doesn't use :data:`sys.platlibdir`. Patch by Victor Stinner.