Added requested modifications
This commit is contained in:
parent
fcbaab8b0b
commit
0b70300ba4
1
AUTHORS
1
AUTHORS
|
@ -227,6 +227,7 @@ Pedro Algarvio
|
||||||
Philipp Loose
|
Philipp Loose
|
||||||
Pieter Mulder
|
Pieter Mulder
|
||||||
Piotr Banaszkiewicz
|
Piotr Banaszkiewicz
|
||||||
|
Piotr Helm
|
||||||
Prashant Anand
|
Prashant Anand
|
||||||
Pulkit Goyal
|
Pulkit Goyal
|
||||||
Punyashloka Biswal
|
Punyashloka Biswal
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
New flags --no-header and --no-summary added. The first one disables header, the second one disables summary.
|
|
@ -115,6 +115,20 @@ def pytest_addoption(parser: Parser) -> None:
|
||||||
dest="verbose",
|
dest="verbose",
|
||||||
help="increase verbosity.",
|
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(
|
group._addoption(
|
||||||
"-q",
|
"-q",
|
||||||
"--quiet",
|
"--quiet",
|
||||||
|
@ -351,6 +365,14 @@ class TerminalReporter:
|
||||||
def showheader(self) -> bool:
|
def showheader(self) -> bool:
|
||||||
return self.verbosity >= 0
|
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
|
@property
|
||||||
def showfspath(self) -> bool:
|
def showfspath(self) -> bool:
|
||||||
if self._showfspath is None:
|
if self._showfspath is None:
|
||||||
|
@ -660,25 +682,26 @@ class TerminalReporter:
|
||||||
return
|
return
|
||||||
self.write_sep("=", "test session starts", bold=True)
|
self.write_sep("=", "test session starts", bold=True)
|
||||||
verinfo = platform.python_version()
|
verinfo = platform.python_version()
|
||||||
msg = "platform {} -- Python {}".format(sys.platform, verinfo)
|
if self.no_header == 0:
|
||||||
pypy_version_info = getattr(sys, "pypy_version_info", None)
|
msg = "platform {} -- Python {}".format(sys.platform, verinfo)
|
||||||
if pypy_version_info:
|
pypy_version_info = getattr(sys, "pypy_version_info", None)
|
||||||
verinfo = ".".join(map(str, pypy_version_info[:3]))
|
if pypy_version_info:
|
||||||
msg += "[pypy-{}-{}]".format(verinfo, pypy_version_info[3])
|
verinfo = ".".join(map(str, pypy_version_info[:3]))
|
||||||
msg += ", pytest-{}, py-{}, pluggy-{}".format(
|
msg += "[pypy-{}-{}]".format(verinfo, pypy_version_info[3])
|
||||||
pytest.__version__, py.__version__, pluggy.__version__
|
msg += ", pytest-{}, py-{}, pluggy-{}".format(
|
||||||
)
|
pytest.__version__, py.__version__, pluggy.__version__
|
||||||
if (
|
)
|
||||||
self.verbosity > 0
|
if (
|
||||||
or self.config.option.debug
|
self.verbosity > 0
|
||||||
or getattr(self.config.option, "pastebin", None)
|
or self.config.option.debug
|
||||||
):
|
or getattr(self.config.option, "pastebin", None)
|
||||||
msg += " -- " + str(sys.executable)
|
):
|
||||||
self.write_line(msg)
|
msg += " -- " + str(sys.executable)
|
||||||
lines = self.config.hook.pytest_report_header(
|
self.write_line(msg)
|
||||||
config=self.config, startdir=self.startdir
|
lines = self.config.hook.pytest_report_header(
|
||||||
)
|
config=self.config, startdir=self.startdir
|
||||||
self._write_report_lines_from_hooks(lines)
|
)
|
||||||
|
self._write_report_lines_from_hooks(lines)
|
||||||
|
|
||||||
def _write_report_lines_from_hooks(
|
def _write_report_lines_from_hooks(
|
||||||
self, lines: List[Union[str, List[str]]]
|
self, lines: List[Union[str, List[str]]]
|
||||||
|
@ -775,7 +798,7 @@ class TerminalReporter:
|
||||||
ExitCode.USAGE_ERROR,
|
ExitCode.USAGE_ERROR,
|
||||||
ExitCode.NO_TESTS_COLLECTED,
|
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(
|
self.config.hook.pytest_terminal_summary(
|
||||||
terminalreporter=self, exitstatus=exitstatus, config=self.config
|
terminalreporter=self, exitstatus=exitstatus, config=self.config
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue