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

Method test_sysconfigdata_json

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

Source from the content-addressed store, hash-verified

689 @unittest.skipIf(is_wasi, "_sysconfig-vars JSON file currently isn't available on WASI")
690 @unittest.skipIf(is_android or is_apple_mobile, 'Android and iOS change the prefix')
691 def test_sysconfigdata_json(self):
692 if '_PYTHON_SYSCONFIGDATA_PATH' in os.environ:
693 data_dir = os.environ['_PYTHON_SYSCONFIGDATA_PATH']
694 elif is_python_build():
695 data_dir = os.path.join(_PROJECT_BASE, _get_pybuilddir())
696 else:
697 data_dir = sys._stdlib_dir
698
699 json_data_path = os.path.join(data_dir, _get_json_data_name())
700
701 with open(json_data_path) as f:
702 json_config_vars = json.load(f)
703
704 system_config_vars = get_config_vars()
705
706 # Keys dependent on uncontrollable external context
707 ignore_keys = {'userbase'}
708 # Keys dependent on Python being run outside the build directrory
709 if sysconfig.is_python_build():
710 ignore_keys |= {'srcdir'}
711 # Keys dependent on the executable location
712 if os.path.dirname(sys.executable) != system_config_vars['BINDIR']:
713 ignore_keys |= {'projectbase'}
714 # Keys dependent on the environment (different inside virtual environments)
715 if sys.prefix != sys.base_prefix:
716 ignore_keys |= {'prefix', 'exec_prefix', 'base', 'platbase'}
717 # Keys dependent on Python being run from the prefix targetted when building (different on relocatable installs)
718 if sysconfig._installation_is_relocated():
719 ignore_keys |= {'prefix', 'exec_prefix', 'base', 'platbase', 'installed_base', 'installed_platbase', 'srcdir'}
720
721 for key in ignore_keys:
722 json_config_vars.pop(key, None)
723 system_config_vars.pop(key, None)
724
725 self.assertEqual(system_config_vars, json_config_vars)
726
727 def test_sysconfig_config_vars_no_prefix_cache(self):
728 sys.prefix = 'prefix-AAA'

Callers

nothing calls this directly

Calls 10

is_python_buildFunction · 0.90
_get_pybuilddirFunction · 0.90
_get_json_data_nameFunction · 0.90
get_config_varsFunction · 0.90
openFunction · 0.50
joinMethod · 0.45
loadMethod · 0.45
dirnameMethod · 0.45
popMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected