Skip to content

Fine grain output verbosity #11387

@plannigan

Description

@plannigan

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):

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: reportingrelated to terminal output and user-facing messages and errorstype: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions