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

Method get_expected_config

Lib/test/test_embed.py:843–898  ·  view source on GitHub ↗
(self, expected_preconfig, expected,
                            env, api, modify_path_cb=None)

Source from the content-addressed store, hash-verified

841 return configs
842
843 def get_expected_config(self, expected_preconfig, expected,
844 env, api, modify_path_cb=None):
845 configs = self._get_expected_config()
846
847 pre_config = configs['pre_config']
848 for key, value in expected_preconfig.items():
849 if value is self.GET_DEFAULT_CONFIG:
850 expected_preconfig[key] = pre_config[key]
851
852 if not expected_preconfig['configure_locale'] or api == API_COMPAT:
853 # there is no easy way to get the locale encoding before
854 # setlocale(LC_CTYPE, "") is called: don't test encodings
855 for key in ('filesystem_encoding', 'filesystem_errors',
856 'stdio_encoding', 'stdio_errors'):
857 expected[key] = self.IGNORE_CONFIG
858
859 if expected_preconfig['utf8_mode'] == 1:
860 if expected['filesystem_encoding'] is self.GET_DEFAULT_CONFIG:
861 expected['filesystem_encoding'] = 'utf-8'
862 if expected['filesystem_errors'] is self.GET_DEFAULT_CONFIG:
863 expected['filesystem_errors'] = self.UTF8_MODE_ERRORS
864 if expected['stdio_encoding'] is self.GET_DEFAULT_CONFIG:
865 expected['stdio_encoding'] = 'utf-8'
866 if expected['stdio_errors'] is self.GET_DEFAULT_CONFIG:
867 expected['stdio_errors'] = 'surrogateescape'
868
869 if MS_WINDOWS:
870 default_executable = self.test_exe
871 elif expected['program_name'] is not self.GET_DEFAULT_CONFIG:
872 default_executable = os.path.abspath(expected['program_name'])
873 else:
874 default_executable = os.path.join(os.getcwd(), '_testembed')
875 if expected['executable'] is self.GET_DEFAULT_CONFIG:
876 expected['executable'] = default_executable
877 if expected['base_executable'] is self.GET_DEFAULT_CONFIG:
878 expected['base_executable'] = default_executable
879 if expected['program_name'] is self.GET_DEFAULT_CONFIG:
880 expected['program_name'] = './_testembed'
881
882 config = configs['config']
883 for key, value in expected.items():
884 if value is self.GET_DEFAULT_CONFIG:
885 expected[key] = config[key]
886
887 if expected['module_search_paths'] is not self.IGNORE_CONFIG:
888 pythonpath_env = expected['pythonpath_env']
889 if pythonpath_env is not None:
890 paths = pythonpath_env.split(os.path.pathsep)
891 expected['module_search_paths'] = [*paths, *expected['module_search_paths']]
892 if modify_path_cb is not None:
893 expected['module_search_paths'] = expected['module_search_paths'].copy()
894 modify_path_cb(expected['module_search_paths'])
895
896 for key in self.COPY_PRE_CONFIG:
897 if key not in expected_preconfig:
898 expected_preconfig[key] = expected[key]
899
900 def check_pre_config(self, configs, expected):

Callers 1

check_all_configsMethod · 0.95

Calls 6

_get_expected_configMethod · 0.95
itemsMethod · 0.45
abspathMethod · 0.45
joinMethod · 0.45
splitMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected