(self)
| 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 |
no test coverage detected