-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
retain-on-failure discards trace/video if teardown/setup fails in fixtures #117
Comments
Thank you for your bug report! Do you have a solution in mind how to solve it? Because currently we create e.g. tracing after the |
Do I have a solution? Not really. My initial thoughts were altering the line to include https://github.com/microsoft/playwright-pytest/blob/main/pytest_playwright/pytest_playwright.py#L226 So this # If requst.node is missing rep_call, then some error happened during execution
# that prevented teardown, but should still be counted as a failure
failed = request.node.rep_call.failed if hasattr(request.node, "rep_call") else True would change to something like this: # If requst.node is missing rep_call, then some error happened during execution
# that prevented teardown, but should still be counted as a failure
failed = any(
[request.node.rep_call.failed if hasattr(request.node, "rep_call") else True],
[request.node.rep_setup.failed if hasattr(request.node, "rep_setup") else True],
[request.node.rep_teardown.failed if hasattr(request.node, "rep_teardown") else True],
) Sorry, just a quick guess at where I might alter the code. I'm not familiar with exactly how pytest alter's the request object. But I was hoping maybe just expanding the retain-on-failure to include errors during setup/teardown. |
I tried that, but it fails as of today after the context was closed. So it won't work. We'd need a different point where we hook in and close the context and manipulate fixture teardown order. |
@mxschmitt Looks like this is more general problem: any test artifacts relay on |
Hi Thanks! Are you interested in contributing a fix with a test? |
yes, I can give a shot) |
@mxschmitt I have tried a lot of things using TDD. Also I found related bug on
|
@mxschmitt I solved all the problems above, can you review? |
From what I can see, if a fixture fails in setup/teardown, the
pytest --output .out --tracing retain-on-failure
discards the trace. And at least sometimes the user will want the trace to be kept.The code only looks at whether the
rep_call
has failed. https://github.com/microsoft/playwright-pytest/blob/main/pytest_playwright/pytest_playwright.py#L224-L226But that ignores issues in the setup/teardown, e.g. pytests the example code
So if a user writes a fixture, that does something with a page in it's setup or teardown, and that setup or teardown code fails, the trace/video will be discarded. That's because at this point pytest will set
rep_setup.failed
(or rep_teardown) to be true, rather thanrep_call.failed
, I believe. Docs for the runtest_protocolThe text was updated successfully, but these errors were encountered: