Open plannigan opened 1 year ago
Started working on this and unsurprisingly realized that how config.options.verbose
is used currently is a bit complicated. So I took the time to see all the places that it is used. The following was based off 6c2feb75d (current head of main):
The vast majority of uses of the verbose setting are within _pytest.terminal. In addition to using it directly, TerminalReporter
also re-exposes it as a property. The pytest
code base does not use the property outside of the TerminalReporter
class.
TerminalReporter
is exposed to
plugins as part of the pytest_terminal_summary()
hook.Config
object is also exposed to plugins: Either directly in a hook (example) or indirectly (example)config.options.verbose
outside of TerminalReporter
--log-cli-level
is provided or log_cli
is set) AND terminalreporter plugin exists)
config.getoption("verbose")
config.options.verbose
usageDEFAULT_REPR_MAX_SIZE
* 10DEFAULT_REPR_MAX_SIZE
config.options.verbose
in TerminalReporter
--collect-only
passed and the session has item, > -1 write empty line before printing collected items --collect-only
)
TerminalReporter.verbosity
propertyA read-only property exposed by TerminalReporter that exposes config.options.verbose
_locationline()
showlongtestinfo
is False
PYTEST_DEBUG
- When set, pytest will print tracing and debug information.--no-header
& --no-summary
: explicitly disable to named terminal output component.That reference is helpful to understand what things accessing verbosity and how. But it's not the easiest to understand the full behavior. So I went through and documented the behavior by verbosity level. (This helped me get a better understanding of specific aspects that can be controlled.)
DEFAULT_REPR_MAX_SIZE
--collect-only
) write filenames and count of items in fileDEFAULT_REPR_MAX_SIZE
--collect-only
) write each item (filename and item name)DEFAULT_REPR_MAX_SIZE
--collect-only
) write tree view of each itemDEFAULT_REPR_MAX_SIZE
* 10--collect-only
) write tree view of each item with docstring--collect-only
) write tree view of each item with docstringI completely missed assertions.util
on the first pass (oops). I updated the previous comments with the missing details.
Should this really have been closed, since (from what I can gather) only a small part of the proposal is implemented so far?
True!
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: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
verbosity_{OUTPUT_TYPE}
seems reasonable to me.