Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-131178: Add tests for ast command-line interface #133329

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 11 commits into from
May 4, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Rewrite tests with help messages
  • Loading branch information
donBarbos committed May 4, 2025
commit 42ff309fbeeee688efa5776e71a9602c1a72cd1b
16 changes: 6 additions & 10 deletions 16 Lib/test/test_ast/test_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -3230,18 +3230,14 @@ def f(x: int) -> int:
with self.subTest(flags=args):
self.invoke_ast(*args)

def test_unknown_flag(self):
with self.assertRaises(SystemExit):
output = self.invoke_ast('--unknown')
self.assertStartsWith(output, 'usage: ')

def test_help_flag(self):
# test 'python -m ast -h/--help'
for flag in ('-h', '--help'):
def test_help_message(self):
for flag in ('-h', '--help', '--unknown'):
with self.subTest(flag=flag):
output = StringIO()
with self.assertRaises(SystemExit):
output = self.invoke_ast(flag)
self.assertStartsWith(output, 'usage: ')
with contextlib.redirect_stderr(output):
ast.main(args=(flag))
donBarbos marked this conversation as resolved.
Show resolved Hide resolved
self.assertStartsWith(output.getvalue(), 'usage: ')

def test_exec_mode_flag(self):
# test 'python -m ast -m/--mode exec'
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.