fix(pytest): capture logs for fixture setup failures#471
Merged
Conversation
When a test fails during fixture setup, pytest reports it as ERROR and the call phase never runs. The previous condition `call.when == "call"` meant _attach_logs was never invoked for setup-phase failures, so log.txt, stdout.txt, and stderr.txt were missing from Qase results. Extend the condition to also attach logs when `call.when == "setup"` and `report.failed`, ensuring setup-failure logs are captured without duplicating attachments for passing tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ERRORand thecallphase never runscall.when == "call"meant_attach_logswas never invoked for setup-phase failureslog.txt,stdout.txt, andstderr.txtwere missing from Qase results for these errorscall.when == "setup"andreport.failedChanges
qase-pytest/src/qase/pytest/plugin.py— extended log attachment condition to cover setup failuresqase-pytest/tests/tests_qase_pytest/test_plugin.py— 4 unit tests covering the new behavior via hookwrapper simulationexamples/single/pytest/tests/test_fixture_setup_failure.py— example tests demonstrating the fixTest plan
test_logs_attached_on_setup_failure— logs captured on fixture ERRORtest_logs_not_attached_on_setup_success— no duplication for passing teststest_logs_still_attached_on_call_phase— existing behavior preservedtest_logs_not_attached_when_capture_logs_disabled— respects configCloses #470 (alternative implementation)