Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate terminal verbosity from diff verbosity #6723

Closed
nicoddemus opened this issue Feb 13, 2020 · 7 comments
Closed

Separate terminal verbosity from diff verbosity #6723

nicoddemus opened this issue Feb 13, 2020 · 7 comments
Labels
topic: config related to config handling, argument parsing and config file topic: reporting related to terminal output and user-facing messages and errors type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@nicoddemus
Copy link
Member

Currently -v controls both terminal verbosity (how to display test session progress in the terminal) and diff verbosity (how verbose is our diffs when assertions fail).

I've often wanted to increase diff verbosity while also keeping terminal verbosity at the normal level, but this is not possible today.

Proposal

Introduce a new option that controls only diff verbosity (for discussion here -dv, but please let's bikeshed on this).

For backward compatibility reasons, -v keeps controlling both terminal verbosity and diff verbosity, but -dv can be used to increase diff verbosity independently.

  • -v: when used, increase both terminal verbosity and diff verbosity.
  • -dv: when used, increase diff verbosity only (we also need the equivalent of -q for diff verbosity).

With -dv in place, we might even consider changing to a higher level of diff verbosity in the future by default, but that remains to be seen.

Related: #6292, #5192

@nicoddemus nicoddemus added type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature topic: reporting related to terminal output and user-facing messages and errors labels Feb 13, 2020
@blueyed
Copy link
Contributor

blueyed commented Feb 13, 2020

I have assert_truncate_level already (blueyed#63), but it only affects the truncation of lines (which is related to diffs / what you want, but yet another knob in this regard).

I'm planning to have something like assert_verbosity_level that would be added/substracted from verbosity for all of the assertion rewriting (including truncating lines - I will likely remove assert_truncate_level then, or keep it (based on assert_verbosity_level then)).

This could also default to "auto", which means that it would be 2 for running on CI.

Related: #6292, #5192

#5192 is a bug, not really related to having the option / control for it.
#3962 is related however.

@bluetech
Copy link
Member

I almost always use -v/-vv just the get the full diff, and in these cases I always prefer not to increase the terminal verbosity. So 👍 from me.


Will the diff is truncated, to see full diff pass -v message be changed to the new flag?


How does the parsing of -dv work? Is -d a flag that just modifies what -v does? I think this doesn't compose very well, e.g. if I have pytest -dv long_test_name, and I want terminal verbosity, I expect to be able to just quickly jump to the end of the line and append -v, but it wouldn't work. So I prefer to just have -d and -dd as standalone flags.

With -dv in place, we might even consider changing to a higher level of diff verbosity in the future by default, but that remains to be seen.

In that case there will also need to be a flag to decrease the default verbosity, so should consider it in the bikesheding.

@blueyed blueyed added the topic: config related to config handling, argument parsing and config file label Feb 13, 2020
@strokirk
Copy link

Adding this as a config option (rather than a CLI-flag) as a first step would work well for me, since I almost always want the highest level of verbosity for tests.

@iliakur
Copy link

iliakur commented Jun 13, 2021

Is there still interest in this? I use -v almost exclusively for diffs and find the extra terminal output rather distracting, so I'm quite motivated to tackle this.

I'm a bit strapped for time, however, and I'm not very experienced with the codebase so will likely need guidance.

@nicoddemus
Copy link
Member Author

nicoddemus commented Jun 14, 2021

@iliakur thanks for volunteering! Yes definitely there's still interest in this.

Beside the original post, we also need to consider the remarks in #6723 (comment).

I'm a bit strapped for time, however, and I'm not very experienced with the codebase so will likely need guidance.

Sure, we are glad to provide it. To get you started, you can see that -v is declared here:

def pytest_addoption(parser: Parser) -> None:
group = parser.getgroup("terminal reporting", "reporting", after="general")
group._addoption(
"-v",
"--verbose",
action="count",
default=0,
dest="verbose",
help="increase verbosity.",
)

And is used like this throughout the codebase:

if self.config.option.verbose < 0:
if self.config.option.verbose < -1:
counts = Counter(item.nodeid.split("::", 1)[0] for item in items)

So we need to review everywhere the option is used and adapt it for the new flags (which we still need to decide precisely).

Let us know if this is enough to at least get started. 👍

@iliakur
Copy link

iliakur commented Jan 19, 2024

@nicoddemus should this be closed as implemented by #11387?

@nicoddemus
Copy link
Member Author

Sure, thanks for the ping!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: config related to config handling, argument parsing and config file topic: reporting related to terminal output and user-facing messages and errors type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

No branches or pull requests

5 participants