MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_user_similar

Method test_user_similar

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

Source from the content-addressed store, hash-verified

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