GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `ast.main` is not covered · Issue #101821 · python/cpython

ast.main is not covered #101821

New issue
Copy link
New issue
Copy link
Closed
Closed
ast.main is not covered#101821
Copy link
Assignees
sobolevn
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@sobolevn
sobolevn
opened on Feb 11, 2023
Issue body actions

All this code is not covered:

cpython/Lib/ast.py

Lines 1712 to 1737 in b652d40

def main():
import argparse
parser = argparse.ArgumentParser(prog='python -m ast')
parser.add_argument('infile', type=argparse.FileType(mode='rb'), nargs='?',
default='-',
help='the file to parse; defaults to stdin')
parser.add_argument('-m', '--mode', default='exec',
choices=('exec', 'single', 'eval', 'func_type'),
help='specify what kind of code must be parsed')
parser.add_argument('--no-type-comments', default=True, action='store_false',
help="don't add information about type comments")
parser.add_argument('-a', '--include-attributes', action='store_true',
help='include attributes such as line numbers and '
'column offsets')
parser.add_argument('-i', '--indent', type=int, default=3,
help='indentation of nodes (number of spaces)')
args = parser.parse_args()
with args.infile as infile:
source = infile.read()
tree = parse(source, args.infile.name, args.mode, type_comments=args.no_type_comments)
print(dump(tree, include_attributes=args.include_attributes, indent=args.indent))
if __name__ == '__main__':
main()

Proof: https://github.com/python/cpython/blob/b652d40f1c88fcd8595cd401513f6b7f8e499471/Lib/test/test_ast.py

If I remove def main, tests still pass.

So, my proposal is: add a simple test case that ensures that ast.main is there. I don't think that we need any fancy stuff. ast.main is only a thin wrapper around ast.parse and ast.dump which are fully tested on their own.

Linked PRs

  • gh-101821: Cover ast.main function #101822

Activity

  1. sobolevn
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    testsTests in the Lib/test dirTests in the Lib/test dir
    on Feb 11, 2023
  2. sobolevn
    self-assigned this
    on Feb 11, 2023
  3. sobolevn
    added 2 commits that reference this issue on Feb 11, 2023

    pythongh-101821: Cover `ast.main` function

    770299a

    pythongh-101821: Cover `ast.main` function

    a5821a9
  4. hauntsaninja
    added a commit that references this issue on Mar 11, 2023

    gh-101821: Test coverage for `ast.main` function (#101822)

    bb396ee
  5. hauntsaninja
    closed this as completedon Mar 11, 2023
  6. iritkatriel
    added a commit that references this issue on Mar 12, 2023

    pythongh-101821: Test coverage for `ast.main` function (python#101822)

    f955ac9
  7. warsaw
    added a commit that references this issue on Apr 11, 2023

    pythongh-101821: Test coverage for `ast.main` function (python#101822)

    76610db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @sobolevn
    sobolevn

Labels

testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402520 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.