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

Issue 6292 - Add option to decrease terminal verbosity despite high diff verbosity. #7178

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ Pedro Algarvio
Philipp Loose
Pieter Mulder
Piotr Banaszkiewicz
Piotr Helm
Pulkit Goyal
Punyashloka Biswal
Quentin Pradet
Expand Down
1 change: 1 addition & 0 deletions changelog/6292.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
New flag -d added which decrease terminal verbosity. Combined with -v/-vv allows to modify how to display test session progress in the terminal.
19 changes: 16 additions & 3 deletions src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ def pytest_addoption(parser):
dest="verbose",
help="increase verbosity.",
)
group._addoption(
"--dt",
action="count",
default=0,
dest="terminal_verbosity",
help="decrease terminal verbosity.",
)
group._addoption(
"-q",
"--quiet",
Expand Down Expand Up @@ -309,6 +316,10 @@ def _determine_show_progress_info(self):
def verbosity(self):
return self.config.option.verbose

@property
def terminal_verbosity(self):
return self.config.option.terminal_verbosity

@property
def showheader(self):
return self.verbosity >= 0
Expand Down Expand Up @@ -433,7 +444,7 @@ def pytest_deselected(self, items):
def pytest_runtest_logstart(self, nodeid, location):
# ensure that the path is printed before the
# 1st test of a module starts running
if self.showlongtestinfo:
if self.showlongtestinfo and self.terminal_verbosity < 1:
line = self._locationline(nodeid, *location)
self.write_ensure_prefix(line, "")
elif self.showfspath:
Expand Down Expand Up @@ -466,7 +477,7 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:
markup = {"yellow": True}
else:
markup = {}
if self.verbosity <= 0:
if self.verbosity <= 0 or self.terminal_verbosity > 0:
if not running_xdist and self.showfspath:
self.write_fspath_result(rep.nodeid, letter, **markup)
else:
Expand Down Expand Up @@ -497,7 +508,9 @@ def _is_last_item(self):

def pytest_runtest_logfinish(self, nodeid):
assert self._session
if self.verbosity <= 0 and self._show_progress_info:
if (
self.verbosity <= 0 or self.terminal_verbosity > 0
) and self._show_progress_info:
if self._show_progress_info == "count":
num_tests = self._session.testscollected
progress_length = len(" [{}/{}]".format(str(num_tests), str(num_tests)))
Expand Down