diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index ea26d9368..02b7d1b60 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -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":