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

Method _get_expected_config_impl

Lib/test/test_embed.py:796–825  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

794 return xoptions
795
796 def _get_expected_config_impl(self):
797 env = remove_python_envvars()
798 code = textwrap.dedent('''
799 import json
800 import sys
801 import _testinternalcapi
802
803 configs = _testinternalcapi.get_configs()
804
805 data = json.dumps(configs)
806 data = data.encode('utf-8')
807 sys.stdout.buffer.write(data)
808 sys.stdout.buffer.flush()
809 ''')
810
811 # Use -S to not import the site module: get the proper configuration
812 # when test_embed is run from a venv (bpo-35313)
813 args = [sys.executable, '-S', '-c', code]
814 proc = subprocess.run(args, env=env,
815 stdout=subprocess.PIPE,
816 stderr=subprocess.PIPE)
817 if proc.returncode:
818 raise Exception(f"failed to get the default config: "
819 f"stdout={proc.stdout!r} stderr={proc.stderr!r}")
820 stdout = proc.stdout.decode('utf-8')
821 # ignore stderr
822 try:
823 return json.loads(stdout)
824 except json.JSONDecodeError:
825 self.fail(f"fail to decode stdout: {stdout!r}")
826
827 def _get_expected_config(self):
828 cls = InitConfigTests

Callers 1

_get_expected_configMethod · 0.95

Calls 6

remove_python_envvarsFunction · 0.85
dedentMethod · 0.45
runMethod · 0.45
decodeMethod · 0.45
loadsMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected