pytest-dev / pytest-dev/pytest

Fine grain output verbosity

Open
#11,387 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: reporting type: proposal
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

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

  • #6723
  • #3962
  • #5285
  • #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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing how pytest uses config.option.verbose and the output paths related to diff verbosity, then compare the linked issues #6723, #3962, #5285, and #6292. Define the abstraction and verbosity_{OUTPUT_TYPE} naming convention, implement only diff verbosity initially, and verify that unspecified settings fall back to the normal verbose level.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.