Repository navigation
Add tests for command-line interface #131178
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancementtestsTests in the Lib/test dirTests in the Lib/test dir
on Mar 13, 2025 See also the tests added in #118132, based on https://pythontest.com/testing-argparse-apps/
Reacted by Semyon Moroz and QuinzyW@donbarbos I assigned this issue to you, since you mentioned that you are working on it :)
Reacted by Semyon Moroz- added a commit that references this issue
on May 4, 2025 61 remaining items
I'd like to work on adding CLI tests for pydoc. I'll open a PR soon.
I am interested in adding command-line interface tests for compileall.
Is this module still available to work on under gh-131178?I'd like to take
code. Its CLI is the__main__block inLib/code.pywith a single-qflag. There's nomain(), so I plan to run it as a subprocess withscript_helperand feed it stdin. The tests will cover:- the default banner and exit message
-qsuppressing the banner, andpython -q -m codedoing the same throughsys.flags.quiet- input piped on stdin being executed
-hand an unknown option
-qisn't documented inDoc/library/code.rst. Should I add a short CLI section in the same PR, or keep this one to tests only?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!
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:
tokenize(gh-131178: Add tests fortokenizecommand-line interface #131274)platform(gh-131524: Update platform CLI to use argparse #131542)pickle(gh-131178: Add tests forpicklecommand-line interface #131275)ast(gh-131178: Add tests forastcommand-line interface #133329)pickletools(gh-131178: Add tests forpickletoolscommand-line interface #131287)http.server(gh-131178: Add tests for http.server command-line interface #132540)profile(gh-131178: Add CLI tests for profile module #134103)cProfile(gh-131178: Add CLI tests for cProfile #134269)site( gh-131178: Add tests forsitecommand-line interface #133582)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
dismodule or #118132 forrandommodule as a reference.And I also suggest using
subprocess.Popento allocate a separate resource since some modules can block a lot of time.Important
For those who want to work on the issue, please:
gh-131178: Add tests for `MODULE_NAME` command-line interfaceLinked PRs
tokenizecommand-line interface #131274picklecommand-line interface #131275pickletoolscommand-line interface #131287timeitCLI #131326astcommand-line interface #133329sitecommand-line interface #133582http.servercommand-line interface #134224http.servercommand-line interface #134279http.serverCLI #134287support.captured_stdoutandsupport.captured_stderr#137748test_unknown_flagfor platform CLI #137816sitecommand-line interface (GH-133582) #137832sitecommand-line interface (GH-133582) #137833sysconfigcommand-line interface #139934filecmpcommand-line interface #139947quopricommand-line interface #149825thiscommand-line interface #151855pstatscommand-line interface #157133ensurepipcommand-line interface #157154profilemodule command-line interface #158542codecommand-line interface #158588calendarcommand-line interface #159045