Skip to content

Add tests for command-line interface #131178

Description

@donbarbos

While working on #130160 and #93096 it was decided that it would be worth paying attention to the problem of lack of tests for command line interface.

List of all cli modules is in the documentation: https://docs.python.org/dev/library/cmdline.html

Many modules are missing command line interface tests, so I suggest using this issue to submit PRs for now only for well-documented interfaces, for example:

TODO: Make sure all documented have tests for CLI (others are not so important as it has not been decided what to do with them yet)

You can use PR #127759 for dis module or #118132 for random module as a reference.
And I also suggest using subprocess.Popen to allocate a separate resource since some modules can block a lot of time.

Important

For those who want to work on the issue, please:

  • Select one module for which tests will be improved. It's easier to review and backport.
  • Open a pull request with the following title: gh-131178: Add tests for `MODULE_NAME` command-line interface

Linked PRs

Activity

  1. added
    type-featureA feature request or enhancement
    testsTests in the Lib/test dir
    on Mar 13, 2025
  2. hugovk commented on Mar 13, 2025

    @hugovk
    Member

    See also the tests added in #118132, based on https://pythontest.com/testing-argparse-apps/

  3. sobolevn commented on Mar 13, 2025

    @sobolevn
    Member

    @donbarbos I assigned this issue to you, since you mentioned that you are working on it :)

  4. added 2 commits that reference this issue on Mar 27, 2025
  5. added a commit that references this issue on Apr 1, 2025
  6. added a commit that references this issue on Apr 6, 2025
  7. added a commit that references this issue on May 4, 2025
  8. added 3 commits that reference this issue on May 7, 2025
  9. 61 remaining items

  10. added 2 commits that reference this issue on Jun 21, 2026
  11. tangyuan0821 commented on Jun 23, 2026

    @tangyuan0821
    Contributor

    I'd like to work on adding CLI tests for pydoc. I'll open a PR soon.

  12. added 2 commits that reference this issue on Jun 23, 2026
  13. added 2 commits that reference this issue on Jun 24, 2026
  14. added 2 commits that reference this issue on Aug 31, 2026
  15. Ghd-2077 commented on Sep 4, 2026

    @Ghd-2077

    I am interested in adding command-line interface tests for compileall.
    Is this module still available to work on under gh-131178?

  16. Ar-maan05 commented on Sep 26, 2026

    @Ar-maan05
    Contributor

    I have opened #149825 (quopri) and #149868 (json) for this issue. Both are ready for review and CI passes. If someone has time to take a look, I'd appreciate it.

  17. cprentice9 commented on Oct 2, 2026

    @cprentice9

    I'd like to take code. Its CLI is the __main__ block in Lib/code.py with a single -q flag. There's no main(), so I plan to run it as a subprocess with script_helper and feed it stdin. The tests will cover:

    • the default banner and exit message
    • -q suppressing the banner, and python -q -m code doing the same through sys.flags.quiet
    • input piped on stdin being executed
    • -h and an unknown option

    -q isn't documented in Doc/library/code.rst. Should I add a short CLI section in the same PR, or keep this one to tests only?

  18. jikekei commented on Oct 10, 2026

    @jikekei

    Hi, I'd like to contribute CLI subprocess tests for the symtable module under #131178.
    I noticed that test_symtable.py already tests symtable.main() directly, but doesn't appear to test invocation through python -m symtable.
    Would adding subprocess tests for successful execution and error handling be a useful contribution? Thank you!

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

Metadata

Metadata

Assignees

Labels

easytestsTests in the Lib/test dirtype-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions