Title: gh-131178: Add tests for `pstats` command-line interface by iamsharduld · Pull Request #157133 · python/cpython · GitHub
Open Graph Title: gh-131178: Add tests for `pstats` command-line interface by iamsharduld · Pull Request #157133 · python/cpython
X Title: gh-131178: Add tests for `pstats` command-line interface by iamsharduld · Pull Request #157133 · python/cpython
Description: Adds tests for the interactive profile browser started by python -m pstats, which had none (test_pstats.py only covered the Stats API). The browser only exists inside the module's __main__ block, so the tests run it in a subprocess with script_helper.spawn_python() and feed commands on stdin. A small profile is generated once per class with cProfile from two module-level functions, one of which calls the other three times, so the expected call counts, callers and callees are known. Covered: Startup banner, prompt, quit, and EOF on stdin. A profile given on the command line, several profiles (added together), and a missing one. read (with an argument, without one to reload, missing file, non-marshal file) and add (including a missing file). stats with an integer, a fraction, a regular expression, and an out-of-range fraction. sort by a full key and by a unique prefix, sort with no or an invalid key, reverse, strip. callers and callees. help and help stats. Every command's behaviour when no statistics are loaded. 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_pstats repeatedly, make patchcheck and the pre-commit hooks on macOS. Issue: gh-131178
Open Graph Description: Adds tests for the interactive profile browser started by python -m pstats, which had none (test_pstats.py only covered the Stats API). The browser only exists inside the module's __main__ bloc...
X Description: Adds tests for the interactive profile browser started by python -m pstats, which had none (test_pstats.py only covered the Stats API). The browser only exists inside the module's __main__ ...
Opengraph URL: https://github.com/python/cpython/pull/157133
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:56b3d4c6-a11d-ea75-3cc6-1ed8ec5bd80d |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A27A:296654:3661DA2:486DB79:6B020B5F |
| html-safe-nonce | 017560ebe70cd8a3bb8abb51e36a7a1d1ce04037b31c99d5ce503196c0c094a3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjdBOjI5NjY1NDozNjYxREEyOjQ4NkRCNzk6NkIwMjBCNUYiLCJ2aXNpdG9yX2lkIjoiMjYxMjE2MTEwMDc2MTkyNjQ5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 22ed450ed653236848a90be154fc92498e9b162e1cbef60dbd05046fd860206e |
| hovercard-subject-tag | pull_request:4467378918 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/157133/files |
| twitter:image | https://avatars.githubusercontent.com/u/8417988?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/8417988?s=400&v=4 |
| og:image:alt | Adds tests for the interactive profile browser started by python -m pstats, which had none (test_pstats.py only covered the Stats API). The browser only exists inside the module's __main__ bloc... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width