Skip to content

gh-116858: Add @cpython_only to several tests in test_cmd_line #116859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Lib/test/test_cmd_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def verify_valid_flag(self, cmd_line):
self.assertNotIn(b'Traceback', err)
return out

@support.cpython_only
def test_help(self):
self.verify_valid_flag('-h')
self.verify_valid_flag('-?')
Expand All @@ -48,14 +49,17 @@ def test_help(self):
self.assertNotIn(b'-X dev', out)
self.assertLess(len(lines), 50)

@support.cpython_only
def test_help_env(self):
out = self.verify_valid_flag('--help-env')
self.assertIn(b'PYTHONHOME', out)

@support.cpython_only
def test_help_xoptions(self):
out = self.verify_valid_flag('--help-xoptions')
self.assertIn(b'-X dev', out)

@support.cpython_only
def test_help_all(self):
out = self.verify_valid_flag('--help-all')
lines = out.splitlines()
Expand All @@ -74,6 +78,7 @@ def test_optimize(self):
def test_site_flag(self):
self.verify_valid_flag('-S')

@support.cpython_only
def test_version(self):
version = ('Python %d.%d' % sys.version_info[:2]).encode("ascii")
for switch in '-V', '--version', '-VV':
Expand Down Expand Up @@ -139,6 +144,7 @@ def run_python(*args):
else:
self.assertEqual(err, b'')

@support.cpython_only
def test_xoption_frozen_modules(self):
tests = {
('=on', 'FrozenImporter'),
Expand All @@ -153,6 +159,7 @@ def test_xoption_frozen_modules(self):
res = assert_python_ok(*cmd)
self.assertRegex(res.out.decode('utf-8'), expected)

@support.cpython_only
def test_env_var_frozen_modules(self):
tests = {
('on', 'FrozenImporter'),
Expand Down Expand Up @@ -579,6 +586,7 @@ def test_del___main__(self):
print("del sys.modules['__main__']", file=script)
assert_python_ok(filename)

@support.cpython_only
def test_unknown_options(self):
rc, out, err = assert_python_failure('-E', '-z')
self.assertIn(b'Unknown option: -z', err)
Expand Down Expand Up @@ -691,6 +699,7 @@ def run_xdev(self, *args, check_exitcode=True, xdev=True):
self.assertEqual(proc.returncode, 0, proc)
return proc.stdout.rstrip()

@support.cpython_only
def test_xdev(self):
# sys.flags.dev_mode
code = "import sys; print(sys.flags.dev_mode)"
Expand Down Expand Up @@ -914,6 +923,7 @@ def test_argv0_normalization(self):
self.assertEqual(proc.returncode, 0, proc)
self.assertEqual(proc.stdout.strip(), b'0')

@support.cpython_only
def test_parsing_error(self):
args = [sys.executable, '-I', '--unknown-option']
proc = subprocess.run(args,
Expand Down