From 82b992a5fd4bca9a6eb215873ce22113d54da387 Mon Sep 17 00:00:00 2001 From: reginaldl Date: Thu, 23 Feb 2017 11:31:37 -0800 Subject: [PATCH 1/4] Mark test as complete at teardown. --- xdist/dsession.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xdist/dsession.py b/xdist/dsession.py index 9ddbc2d..3377078 100644 --- a/xdist/dsession.py +++ b/xdist/dsession.py @@ -660,7 +660,7 @@ class DSession: If the node indicates it is finished with a test item, remove the item from the pending list in the scheduler. """ - if rep.when == "call" or (rep.when == "setup" and not rep.passed): + if rep.when == "teardown" or (rep.when == "setup" and not rep.passed): self.sched.mark_test_complete(node, rep.item_index, rep.duration) # self.report_line("testreport %s: %s" %(rep.id, rep.status)) rep.node = node From 99f667380f125c5675490ae2935981431ab28e94 Mon Sep 17 00:00:00 2001 From: reginaldl Date: Thu, 23 Feb 2017 15:01:48 -0800 Subject: [PATCH 2/4] - Reinforce `test_crashing_item` to match test name instead of test file. - Add `test_crashing_item_teardown` to validate crash behavior at teardown. --- testing/acceptance_test.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 2bb7bb1..e30a804 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -437,7 +437,31 @@ def test_crashing_item(testdir): """) result = testdir.runpytest("-n2", p) result.stdout.fnmatch_lines([ - "*crashed*test_crash*", "*1 failed*1 passed*" + "*crashed*::test_crash*", "*1 failed*1 passed*" + ]) + +def test_crashing_item_teardown(testdir): + p = testdir.makepyfile(""" + import py + import pytest + import os + import time + + @pytest.fixture + def crash_fixture(request): + def kill_me(): + py.process.kill(os.getpid()) + request.addfinalizer(kill_me) + + def test_a(crash_fixture): + pass + + def test_b(): + pass + """) + result = testdir.runpytest("-n1", p) + result.stdout.fnmatch_lines([ + "*crashed*::test_a*", "*1 failed*2 passed*" ]) From 602694b8172bc5f7cc62f2af58cb112619ae4b1a Mon Sep 17 00:00:00 2001 From: reginaldl Date: Thu, 23 Feb 2017 15:14:24 -0800 Subject: [PATCH 3/4] Fix missing blank line. --- testing/acceptance_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index e30a804..b0aa0ba 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -440,6 +440,7 @@ def test_crashing_item(testdir): "*crashed*::test_crash*", "*1 failed*1 passed*" ]) + def test_crashing_item_teardown(testdir): p = testdir.makepyfile(""" import py From c79a98c6240b4ce679078ff11fcad6115f9a67bf Mon Sep 17 00:00:00 2001 From: reginaldl Date: Tue, 7 Mar 2017 10:15:52 -0800 Subject: [PATCH 4/4] Add note about #124 to CHANGELOG. --- CHANGELOG | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 18cd054..091a3b5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,10 @@ and ``EachScheduling`` implementations. Note that required scheduler class public API may change in next ``pytest-xdist`` versions. +- fix #124: xdist would mark test as complete after 'call' step. As a result, + xdist could identify the wrong test as failing when test crashes at teardown. + To address this issue, xdist now marks test as complete at teardown. + 1.15.0 ------