Included stdio in choices under Group._addoption to have stdio display both stdout and stderr.

This commit is contained in:
Eichel Choi 2023-12-06 19:02:14 -05:00
parent 0cb5ac389f
commit be0d6e49d9
1 changed files with 18 additions and 4 deletions

View File

@ -217,9 +217,9 @@ def pytest_addoption(parser: Parser) -> None:
"--show-capture",
action="store",
dest="showcapture",
choices=["no", "stdout", "stderr", "log", "all"],
choices=["no", "stdout", "stderr", "log", "stdio", "all"],
default="all",
help="Controls how captured stdout/stderr/log is shown on failed tests. "
help="Controls how captured stdout/stderr/log is shown on failed tests. stdio displays both stdout and stderr. "
"Default: all.",
)
group._addoption(
@ -1039,7 +1039,14 @@ class TerminalReporter:
if showcapture == "no":
return
for secname, content in rep.sections:
if showcapture != "all" and showcapture not in secname:
if (
showcapture != "all"
and showcapture not in secname
and (
showcapture != "stdio"
or ("stderr" not in secname and "stdout" not in secname)
)
):
continue
if "teardown" in secname:
self._tw.sep("-", secname)
@ -1085,7 +1092,14 @@ class TerminalReporter:
if showcapture == "no":
return
for secname, content in rep.sections:
if showcapture != "all" and showcapture not in secname:
if (
showcapture != "all"
and showcapture not in secname
and (
showcapture != "stdio"
or ("stderr" not in secname and "stdout" not in secname)
)
):
continue
self._tw.sep("-", secname)
if content[-1:] == "\n":