Reduce verbosity of @limit_memory failure output - #171
Conversation
41e6b0c to
9655253
Compare
9655253 to
93adbd8
Compare
93adbd8 to
9661579
Compare
75d0033 to
b454962
Compare
godlygeek
left a comment
There was a problem hiding this comment.
This LGTM after the updates I've made, but @sarahmonod would you mind giving it a look as well since I made quite a few changes?
b454962 to
9287c1c
Compare
Add a `verbosity_memray` pytest option that controls whether the
per-allocation list is shown when the `limit_memory` marker fails.
By default the long "List of allocations:" section now shows only the
top 10 allocations by size for each failures. With `-q` or a negative
verbosity setting, only the one-line summary is displayed ("Test was
limited to X but allocated Y"). With `-vv` or a verbosity setting of
2 or more, all allocations are shown, the old default.
Drop support for pytest 7.x, which was superseded around 2.5 years ago
and which doesn't provide the `Config.get_verbosity` API we need.
Signed-off-by: Soojin Yoon <luvbliny@gmail.com>
Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
9287c1c to
84403df
Compare
|
Thanks for the contribution, @blingblin-g! |
|
I think I somehow missed posting a comment explaining what changes I decided to make here, so for posterity: I updated this PR to drop support for pytest 7.x (which is now >2.5 years out of date). pytest 8.x supports every Python version that I also switched it to have 3 tiers instead of just 2: by default, it shows the top 10 allocations by size, with I'm hoping that gives people a bit more info by default without overwhelming them. |
|
Wow, the 3-tier verbosity makes perfect sense! Thanks for polishing my initial PR and merging it. |
Closes #142.
Context — PyCon US sprint
Prototyped at the PyCon US sprint. The first draft rolled its own ini lookup, but a maintainer pointed me at pytest's standard helper for this case:
Config.get_verbosity(verbosity_type). The current implementation defers to that.Why the fallback
Config.get_verbosityonly exists in pytest 8.0+. This package still declarespytest>=7.2, so I kept a smalltry/except AttributeErrorblock that mirrors the helper's behavior on older pytest. Happy to drop it and bumppytest>=8.0instead — say the word and I'll squash.