Code Bug Fix: Pytest alternative to –verbose –verbose (-v -v)

Original Source Link

Is there a single argument alternative to the double verbose options for pytest runs? It’s a little deceptive looking seeming like a merge error or a benign redundant typo when it shows up in shell script source.

I’m not sure the evolution of the verbosity inputs, but its showing up in our repo from tips like the following that pytest gives upon failures.

...Full output truncated (19 lines hidden), use '-vv' to show

Would be nice if there was something like --verbose2 or something of the sort.

Turns out there is such an option, it’s under verbosity.

--verbosity=VERBOSE

and tracing around the codebase seems to imply that 0,1,2 are valid values. There doesn’t appear to be any documentation on that point however.

Looking at the command argument definition I can also see the behavior and pattern they’re utilizing, which is the count action which sheds new light on redundant arguments; I didn’t even realize that was a pattern.

group._addoption(
    "-v",
    "--verbose",
    action="count",
    default=0,
    dest="verbose",
    help="increase verbosity.",
)

So it would seem that

"-vv" === "--verbose --verbose" === "--verbosity=2"

Tagged :

Leave a Reply

Your email address will not be published. Required fields are marked *