diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-07-31 15:58:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-31 15:58:02 (GMT) |
commit | 147a9a8be79fb5666e264175e3047d6d67b50254 (patch) | |
tree | 4946149ab1c89591c662e9e2d6f2f83889277883 /Lib/test | |
parent | db13c0c1b8bc8c15d920a94ca008aabea4037697 (diff) | |
download | cpython-147a9a8be79fb5666e264175e3047d6d67b50254.zip cpython-147a9a8be79fb5666e264175e3047d6d67b50254.tar.gz cpython-147a9a8be79fb5666e264175e3047d6d67b50254.tar.bz2 |
bpo-45445: Revert "bpo-45445: Fail if an invalid X-option is provided in the command line (GH-28823)" (GH-94745)
(cherry picked from commit aa37ffda29ac48fb2df5a7029ba2e626ecc45850)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_audit.py | 4 | ||||
-rw-r--r-- | Lib/test/test_cmd_line.py | 13 | ||||
-rw-r--r-- | Lib/test/test_embed.py | 23 |
3 files changed, 15 insertions, 25 deletions
diff --git a/Lib/test/test_audit.py b/Lib/test/test_audit.py index a7ff038..18426f2 100644 --- a/Lib/test/test_audit.py +++ b/Lib/test/test_audit.py @@ -20,7 +20,7 @@ class AuditTest(unittest.TestCase): @support.requires_subprocess() def do_test(self, *args): with subprocess.Popen( - [sys.executable, "-Xutf8", AUDIT_TESTS_PY, *args], + [sys.executable, "-X utf8", AUDIT_TESTS_PY, *args], encoding="utf-8", stdout=subprocess.PIPE, stderr=subprocess.PIPE, @@ -35,7 +35,7 @@ class AuditTest(unittest.TestCase): def run_python(self, *args): events = [] with subprocess.Popen( - [sys.executable, "-Xutf8", AUDIT_TESTS_PY, *args], + [sys.executable, "-X utf8", AUDIT_TESTS_PY, *args], encoding="utf-8", stdout=subprocess.PIPE, stderr=subprocess.PIPE, diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 83a357f..037606d 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -108,17 +108,8 @@ class CmdLineTest(unittest.TestCase): opts = get_xoptions() self.assertEqual(opts, {}) - opts = get_xoptions('-Xno_debug_ranges', '-Xdev=1234') - self.assertEqual(opts, {'no_debug_ranges': True, 'dev': '1234'}) - - @unittest.skipIf(interpreter_requires_environment(), - 'Cannot run -E tests when PYTHON env vars are required.') - def test_unknown_xoptions(self): - rc, out, err = assert_python_failure('-X', 'blech') - self.assertIn(b'Unknown value for option -X', err) - msg = b'Fatal Python error: Unknown value for option -X (see --help-xoptions)' - self.assertEqual(err.splitlines().count(msg), 1) - self.assertEqual(b'', out) + opts = get_xoptions('-Xa', '-Xb=c,d=e') + self.assertEqual(opts, {'a': True, 'b': 'c,d=e'}) def test_showrefcount(self): def run_python(*args): diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index de3354b..90022db 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -284,7 +284,7 @@ class EmbeddingTests(EmbeddingTestsMixin, unittest.TestCase): "test_pre_initialization_sys_options", env=env) expected_output = ( "sys.warnoptions: ['once', 'module', 'default']\n" - "sys._xoptions: {'dev': '2', 'utf8': '1'}\n" + "sys._xoptions: {'not_an_option': '1', 'also_not_an_option': '2'}\n" "warnings.filters[:3]: ['default', 'module', 'once']\n" ) self.assertIn(expected_output, out) @@ -842,14 +842,15 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): 'argv': ['-c', 'arg2'], 'orig_argv': ['python3', '-W', 'cmdline_warnoption', - '-X', 'dev', + '-X', 'cmdline_xoption', '-c', 'pass', 'arg2'], 'parse_argv': 2, 'xoptions': [ - 'dev=3', - 'utf8', - 'dev', + 'config_xoption1=3', + 'config_xoption2=', + 'config_xoption3', + 'cmdline_xoption', ], 'warnoptions': [ 'cmdline_warnoption', @@ -1077,8 +1078,9 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): config = { 'faulthandler': 1, 'xoptions': [ - 'dev', - 'utf8', + 'config_xoption', + 'cmdline_xoption', + 'sysadd_xoption', 'faulthandler', ], 'warnoptions': [ @@ -1088,12 +1090,9 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): ], 'orig_argv': ['python3', '-W', 'ignore:::cmdline_warnoption', - '-X', 'utf8'], + '-X', 'cmdline_xoption'], } - preconfig = {'utf8_mode': 1} - self.check_all_configs("test_init_sys_add", config, - expected_preconfig=preconfig, - api=API_PYTHON) + self.check_all_configs("test_init_sys_add", config, api=API_PYTHON) def test_init_run_main(self): code = ('import _testinternalcapi, json; ' |