From b4a7a1a8a84ddf18462208aa2333cf4f8e1e113e Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 6 Jun 2016 20:46:25 -0300 Subject: [PATCH] Fix internal error when using --maxfail option Fix #65 Fix #62 --- CHANGELOG | 3 +++ testing/acceptance_test.py | 21 +++++++++++++++++++++ xdist/remote.py | 5 ++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 29c5dd5..247f3a4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,9 @@ - display progress during collection only when in a terminal, similar to pytest #1397 issue. Thanks Bruno Oliveira for the PR. +- fix internal error message when ``--maxfail`` is used (#62, #65). + Thanks Collin RM Stocks and Bryan A. Jones for reports and Bruno Oliveira for the PR. + 1.14 ---- diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index a736ad9..cccb8f7 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -664,3 +664,24 @@ def test_color_yes_collection_on_non_atty(testdir, request): assert '\x1b[1m' in result.stdout.str() assert 'gw0 [10] / gw1 [10]' in result.stdout.str() assert 'gw0 C / gw1 C' not in result.stdout.str() + + +def test_internal_error_with_maxfail(testdir): + """ + Internal error when using --maxfail option (#62, #65). + """ + testdir.makepyfile(""" + import pytest + + @pytest.fixture(params=['1', '2']) + def crasher(): + raise RuntimeError + + def test_aaa0(crasher): + pass + def test_aaa1(crasher): + pass + """) + result = testdir.runpytest_subprocess('--maxfail=1', '-n1') + result.stdout.fnmatch_lines(['* 1 error in *']) + assert 'INTERNALERROR' not in result.stderr.str() diff --git a/xdist/remote.py b/xdist/remote.py index 0d6997f..226262a 100644 --- a/xdist/remote.py +++ b/xdist/remote.py @@ -46,7 +46,10 @@ class SlaveInteractor: self.log("entering main loop") torun = [] while 1: - name, kwargs = self.channel.receive() + try: + name, kwargs = self.channel.receive() + except EOFError: + return True self.log("received command", name, kwargs) if name == "runtests": torun.extend(kwargs['indices'])