Merge 7c04650094
into dc65bb6a66
This commit is contained in:
commit
0347346461
2
AUTHORS
2
AUTHORS
|
@ -185,6 +185,7 @@ Ilya Konstantinov
|
||||||
Ionuț Turturică
|
Ionuț Turturică
|
||||||
Isaac Virshup
|
Isaac Virshup
|
||||||
Israel Fruchter
|
Israel Fruchter
|
||||||
|
Itamar Hindi
|
||||||
Itxaso Aizpurua
|
Itxaso Aizpurua
|
||||||
Iwan Briquemont
|
Iwan Briquemont
|
||||||
Jaap Broekhuizen
|
Jaap Broekhuizen
|
||||||
|
@ -371,6 +372,7 @@ Sanket Duthade
|
||||||
Sankt Petersbug
|
Sankt Petersbug
|
||||||
Saravanan Padmanaban
|
Saravanan Padmanaban
|
||||||
Sean Malloy
|
Sean Malloy
|
||||||
|
Sebin (Eichel) Choi
|
||||||
Segev Finer
|
Segev Finer
|
||||||
Serhii Mozghovyi
|
Serhii Mozghovyi
|
||||||
Seth Junot
|
Seth Junot
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Added stdio as option for --show-capture to have both stderr and stdout output together.
|
|
@ -348,7 +348,13 @@ def _enter_pdb(
|
||||||
("stderr", rep.capstderr),
|
("stderr", rep.capstderr),
|
||||||
("log", rep.caplog),
|
("log", rep.caplog),
|
||||||
):
|
):
|
||||||
if showcapture in (sectionname, "all") and content:
|
if (
|
||||||
|
showcapture in (sectionname, "all")
|
||||||
|
or (
|
||||||
|
showcapture == "stdio"
|
||||||
|
and ("stdout" in sectionname or "stderr" in sectionname)
|
||||||
|
)
|
||||||
|
) and content:
|
||||||
tw.sep(">", "captured " + sectionname)
|
tw.sep(">", "captured " + sectionname)
|
||||||
if content[-1:] == "\n":
|
if content[-1:] == "\n":
|
||||||
content = content[:-1]
|
content = content[:-1]
|
||||||
|
|
|
@ -227,9 +227,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(
|
||||||
|
@ -1084,7 +1084,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)
|
||||||
|
@ -1147,7 +1154,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":
|
||||||
|
|
|
@ -1611,6 +1611,11 @@ def pytest_report_header(config, start_path):
|
||||||
assert "!This is stderr!" not in stdout
|
assert "!This is stderr!" not in stdout
|
||||||
assert "!This is a warning log msg!" in stdout
|
assert "!This is a warning log msg!" in stdout
|
||||||
|
|
||||||
|
stdout = pytester.runpytest("--show-capture=stdio", "--tb=short").stdout.str()
|
||||||
|
assert "!This is stdout!" in stdout
|
||||||
|
assert "!This is stderr!" in stdout
|
||||||
|
assert "!This is a warning log msg!" not in stdout
|
||||||
|
|
||||||
stdout = pytester.runpytest("--show-capture=no", "--tb=short").stdout.str()
|
stdout = pytester.runpytest("--show-capture=no", "--tb=short").stdout.str()
|
||||||
assert "!This is stdout!" not in stdout
|
assert "!This is stdout!" not in stdout
|
||||||
assert "!This is stderr!" not in stdout
|
assert "!This is stderr!" not in stdout
|
||||||
|
@ -1651,6 +1656,11 @@ def pytest_report_header(config, start_path):
|
||||||
assert "!stderr!" not in result
|
assert "!stderr!" not in result
|
||||||
assert "!log!" in result
|
assert "!log!" in result
|
||||||
|
|
||||||
|
result = pytester.runpytest("--show-capture=stdio", "--tb=short").stdout.str()
|
||||||
|
assert "!stdout!" in result
|
||||||
|
assert "!stderr!" in result
|
||||||
|
assert "!log!" not in result
|
||||||
|
|
||||||
result = pytester.runpytest("--show-capture=no", "--tb=short").stdout.str()
|
result = pytester.runpytest("--show-capture=no", "--tb=short").stdout.str()
|
||||||
assert "!stdout!" not in result
|
assert "!stdout!" not in result
|
||||||
assert "!stderr!" not in result
|
assert "!stderr!" not in result
|
||||||
|
|
Loading…
Reference in New Issue