Fix tests skipped during setup phase reporting with no result#102
Fix tests skipped during setup phase reporting with no result#102
Conversation
Tests skipped via @pytest.mark.skip, @pytest.mark.skipif, or pytest.skip() in fixtures produce a setup-phase report with outcome="skipped". The logreport condition only captured setup failures, not setup skips, so the result stayed None and was omitted from the JSON payload — displayed as "unknown" in the UI. Also restructured the capture condition with clearer comments explaining when each phase's outcome is meaningful. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The fix here is correct — nice catch tracing this back from the test-engine-client. This shouldn't hold up the PR, but while reviewing I noticed a few related things worth flagging.
|
Context
This was originally reported as a test-engine-client issue where
OnlyMutedFailures()returns false due to unrecognized test statuses. I traced the root cause back to the test collector itself.When a test is skipped during the setup phase (e.g. via
@pytest.mark.skip,@pytest.mark.skipif, orpytest.skip()in a fixture), the call phase never runs. Thepytest_runtest_logreporthook fires withreport.when="setup"andreport.outcome="skipped", but the existing condition only captured setup failures, not setup skips:This meant
update_test_resultwas never called, so the test'sresultstayedNone. When serialized to JSON, theresultkey was omitted entirely. The test-engine-client then treated this as"unknown", which broke the status accounting inRunResult.Status()and causedOnlyMutedFailures()to return false.Changes
"skipped"in the JSON payload, with a corresponding unit test.Test plan
test_pytest_runtest_logreport_skip_in_setuppasses--jsonoption on a test suite that includes@pytest.mark.skiptests and verify the JSON output contains"result": "skipped"for those tests