MCPcopy Index your code
hub / github.com/python/cpython / test_user_similar

Method test_user_similar

Lib/test/test_sysconfig.py:408–440  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

406 self.assertEqual(py.call_real(*cmd), py.call_link(*cmd))
407
408 def test_user_similar(self):
409 # Issue #8759: make sure the posix scheme for the users
410 # is similar to the global posix_prefix one
411 base = get_config_var('base')
412 if HAS_USER_BASE:
413 user = get_config_var('userbase')
414 # the global scheme mirrors the distinction between prefix and
415 # exec-prefix but not the user scheme, so we have to adapt the paths
416 # before comparing (issue #9100)
417 adapt = sys.base_prefix != sys.base_exec_prefix
418 for name in ('stdlib', 'platstdlib', 'purelib', 'platlib'):
419 global_path = get_path(name, 'posix_prefix')
420 if adapt:
421 global_path = global_path.replace(sys.exec_prefix, sys.base_prefix)
422 base = base.replace(sys.exec_prefix, sys.base_prefix)
423 elif sys.base_prefix != sys.prefix:
424 # virtual environment? Likewise, we have to adapt the paths
425 # before comparing
426 global_path = global_path.replace(sys.base_prefix, sys.prefix)
427 base = base.replace(sys.base_prefix, sys.prefix)
428 if HAS_USER_BASE:
429 user_path = get_path(name, 'posix_user')
430 expected = os.path.normpath(global_path.replace(base, user, 1))
431 # bpo-44860: platlib of posix_user doesn't use sys.platlibdir,
432 # whereas posix_prefix does.
433 if name == 'platlib':
434 # Replace "/lib64/python3.11/site-packages" suffix
435 # with "/lib/python3.11/site-packages".
436 py_version_abi = sysconfig._get_python_version_abi()
437 suffix = f'python{py_version_abi}/site-packages'
438 expected = expected.replace(f'/{sys.platlibdir}/{suffix}',
439 f'/lib/{suffix}')
440 self.assertEqual(user_path, expected)
441
442 def test_main(self):
443 # just making sure _main() runs and returns things in the stdout

Callers

nothing calls this directly

Calls 4

get_config_varFunction · 0.90
get_pathFunction · 0.90
replaceMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected