From 99f667380f125c5675490ae2935981431ab28e94 Mon Sep 17 00:00:00 2001 From: reginaldl Date: Thu, 23 Feb 2017 15:01:48 -0800 Subject: [PATCH] - 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*" ])