Added requested modifications

This commit is contained in:
piotrhm 2020-05-25 14:18:57 +02:00 committed by Bruno Oliveira
parent fcbaab8b0b
commit 0b70300ba4
3 changed files with 45 additions and 20 deletions

View File

@ -227,6 +227,7 @@ Pedro Algarvio
Philipp Loose
Pieter Mulder
Piotr Banaszkiewicz
Piotr Helm
Prashant Anand
Pulkit Goyal
Punyashloka Biswal

View File

@ -0,0 +1 @@
New flags --no-header and --no-summary added. The first one disables header, the second one disables summary.

View File

@ -115,6 +115,20 @@ def pytest_addoption(parser: Parser) -> None:
dest="verbose",
help="increase verbosity.",
)
group._addoption(
"--no-header",
action="count",
default=0,
dest="no_header",
help="disable header",
)
group._addoption(
"--no-summary",
action="count",
default=0,
dest="no_summary",
help="disable summary",
)
group._addoption(
"-q",
"--quiet",
@ -351,6 +365,14 @@ class TerminalReporter:
def showheader(self) -> bool:
return self.verbosity >= 0
@property
def no_header(self) -> bool:
return self.config.option.no_header
@property
def no_summary(self) -> bool:
return self.config.option.no_summary
@property
def showfspath(self) -> bool:
if self._showfspath is None:
@ -660,6 +682,7 @@ class TerminalReporter:
return
self.write_sep("=", "test session starts", bold=True)
verinfo = platform.python_version()
if self.no_header == 0:
msg = "platform {} -- Python {}".format(sys.platform, verinfo)
pypy_version_info = getattr(sys, "pypy_version_info", None)
if pypy_version_info:
@ -775,7 +798,7 @@ class TerminalReporter:
ExitCode.USAGE_ERROR,
ExitCode.NO_TESTS_COLLECTED,
)
if exitstatus in summary_exit_codes:
if exitstatus in summary_exit_codes and self.no_summary == 0:
self.config.hook.pytest_terminal_summary(
terminalreporter=self, exitstatus=exitstatus, config=self.config
)