examples: be more precise about TestReport outcome

* testing only for "failed" should not be reported as "or skipped"
* test for "skipped" explicitly instead
This commit is contained in:
Yann Dirson 2024-06-26 16:02:37 +02:00
parent f74e947c1f
commit 5dd198a38e
2 changed files with 8 additions and 1 deletions

5
changelog/12535.doc.rst Normal file
View File

@ -0,0 +1,5 @@
`This
example`<https://docs.pytest.org/en/latest/example/simple.html#making-test-result-information-available-in-fixtures>
showed ``print`` statements that do not exactly reflect what the
different branches actually do. The fix makes the example more precise.

View File

@ -929,7 +929,9 @@ here is a little example implemented via a local plugin:
# "function" scope
report = request.node.stash[phase_report_key]
if report["setup"].failed:
print("setting up a test failed or skipped", request.node.nodeid)
print("setting up a test failed", request.node.nodeid)
elif report["setup"].skipped:
print("setting up a test skipped", request.node.nodeid)
elif ("call" not in report) or report["call"].failed:
print("executing test failed or skipped", request.node.nodeid)