{{ message }}
gh-131178: Add tests for pstats command-line interface - #157133
Open
iamsharduld wants to merge 3 commits into
Open
gh-131178: Add tests for pstats command-line interface#157133iamsharduld wants to merge 3 commits into
pstats command-line interface#157133iamsharduld wants to merge 3 commits into
Conversation
The interactive profile browser started by ``python -m pstats`` had no tests. Drive it through a subprocess and check each documented command, the prompts, the report header, sorting, restrictions, callers and callees, help, and the error paths.
9 tasks
Contributor
Author
Contributor
|
You should not ping core devs unnecessarily. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds tests for the interactive profile browser started by
python -m pstats, which had none (test_pstats.pyonly covered theStatsAPI).The browser only exists inside the module's
__main__block, so the tests run it in a subprocess withscript_helper.spawn_python()and feed commands on stdin. A small profile is generated once per class withcProfilefrom two module-level functions, one of which calls the other three times, so the expected call counts, callers and callees are known.Covered:
quit, and EOF on stdin.read(with an argument, without one to reload, missing file, non-marshal file) andadd(including a missing file).statswith an integer, a fraction, a regular expression, and an out-of-range fraction.sortby a full key and by a unique prefix,sortwith no or an invalid key,reverse,strip.callersandcallees.helpandhelp stats.Assertions avoid anything timing-dependent: they check call counts, the relative order of the two known functions, and the exact messages printed by the browser. The class is guarded with
support.requires_subprocess(). The 20 new tests take about 1.2 s on a debug build here.Ran
test_pstatsrepeatedly,make patchcheckand the pre-commit hooks on macOS.