-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
What's the problem this feature will solve?
There are multiple open issues that are requesting more control over the output displayed by pytest
. --verbose
turns everything up, but it would be nice to be able to just increase or decrease the verbosity for specific aspects of the output.
Open issues that I've found that fit into this problem space (there may be others):
- Separate terminal verbosity from diff verbosity #6723
- Add distinct option to show full (assertion) diffs always #3962
- parametrize: truncate long parameters in output in
-v
mode, still display full value in-vv
#5285 - Add option to force "short summary" despite high verbosity #6292
Describe the solution you'd like
I think a way that could resolve all of these is to add an abstraction layer on top config.option.verbose
. Rough pseudo-code example:
class OutputVerbosity:
def __init__(self, config_options):
self._options = config_options
self.verbose = self._options.verbose
def verbosity_for(self, output_type):
return getattr(self._options, output_type, self.verbose)
For general cases, the verbose
attribute could be used. For special cases, an output type name could be passed in retrieve the more fine grained setting. If the specific config is not set, it will default to the normal verbose level. Once this is in place, it would be easier to add more cases in the future if they come up.
Implementation
- I should be able to work on an actual implementation. I'd likely start with only implementing diff verbosity since the PR might get large if I attempted to address all of the identified cases at once.
- That being said, I think it makes sense to decide on a naming convention for these configuration fields.
verbosity_{OUTPUT_TYPE}
seems reasonable to me. - I'm leaning towards not providing CLI access to these configuration fields. They feel like they wouldn't be used regularly and it should be easy to add them after the fact if needed.