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", "--show-capture",
action="store", action="store",
dest="showcapture", dest="showcapture",
choices=["no", "stdout", "stderr", "log", "all"], choices=["no", "stdout", "stderr", "log", "stdio", "all"],
default="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.", "Default: all.",
) )
group._addoption( group._addoption(
@ -1039,7 +1039,14 @@ class TerminalReporter:
if showcapture == "no": if showcapture == "no":
return return
for secname, content in rep.sections: 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 continue
if "teardown" in secname: if "teardown" in secname:
self._tw.sep("-", secname) self._tw.sep("-", secname)
@ -1085,7 +1092,14 @@ class TerminalReporter:
if showcapture == "no": if showcapture == "no":
return return
for secname, content in rep.sections: 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 continue
self._tw.sep("-", secname) self._tw.sep("-", secname)
if content[-1:] == "\n": if content[-1:] == "\n":