Skip to content

Commit 070fdcc

Browse files
authored
fix xdist keyerror (fixes $368 via #372)
1 parent 2c7a8a5 commit 070fdcc

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

allure-pytest/src/listener.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def pytest_fixture_post_finalizer(self, fixturedef):
157157

158158
@pytest.hookimpl(hookwrapper=True)
159159
def pytest_runtest_makereport(self, item, call):
160-
uuid = self._cache.push(item.nodeid)
160+
uuid = self._cache.get(item.nodeid)
161161

162162
report = (yield).get_result()
163163

@@ -203,7 +203,8 @@ def pytest_runtest_makereport(self, item, call):
203203
def pytest_runtest_logfinish(self, nodeid, location):
204204
yield
205205
uuid = self._cache.pop(nodeid)
206-
self.allure_logger.close_test(uuid)
206+
if uuid:
207+
self.allure_logger.close_test(uuid)
207208

208209
@allure_commons.hookimpl
209210
def attach_data(self, body, name, attachment_type, extension):
@@ -258,7 +259,7 @@ def push(self, _id):
258259
return self._items.setdefault(str(_id), uuid4())
259260

260261
def pop(self, _id):
261-
return self._items.pop(str(_id))
262+
return self._items.pop(str(_id), None)
262263

263264

264265
def _test_fixtures(item):

allure-pytest/test/integration/pytest_xdistr/pytest_xdistr_select_test.py renamed to allure-pytest/test/integration/pytest_xdist/pytest_xdist_select_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@allure.issue("292")
88
@allure.feature("Integration")
99
@pytest.mark.real_logger
10-
def test_xdistr_and_select_test_by_bdd_label(allured_testdir):
10+
def test_xdist_and_select_test_by_bdd_label(allured_testdir):
1111
"""
1212
>>> import pytest
1313
>>> import allure
@@ -22,7 +22,7 @@ def test_xdistr_and_select_test_by_bdd_label(allured_testdir):
2222
"""
2323

2424
allured_testdir.parse_docstring_source()
25-
allured_testdir.run_with_allure("-v", "--allure-features=boo", "-n2")
25+
allured_testdir.run_with_allure("-v", "--allure-features=boo", "-n1")
2626

2727
assert_that(allured_testdir.allure_report,
2828
has_only_testcases(

allure-pytest/tox.ini

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
22
envlist =
33
py{27,36,37}
4-
; xdist
4+
xdist
55
integration
66
static_check
77

@@ -51,19 +51,21 @@ commands =
5151
[testenv:xdist]
5252
passenv = HOME
5353

54-
basepython = python3.5
55-
56-
whitelist_externals = rm
54+
basepython = python3.7
5755

5856
deps =
5957
pyhamcrest
6058
pytest-xdist
59+
mock
6160
{distshare}/allure-python-commons-2*.zip
6261
{distshare}/allure-python-commons-test-2*.zip
6362

6463
commands =
65-
rm -f {envtmpdir}/*.json
66-
py.test -n 4 --doctest-module --alluredir={envtmpdir} {posargs: ./test/}
64+
py.test --basetemp={envtmpdir}/tmp \
65+
--alluredir={envtmpdir}/allure-results \
66+
-W ignore::pytest.PytestExperimentalApiWarning \
67+
-p pytester \
68+
-n 3 {posargs: ./test/acceptance}
6769

6870

6971
# Run tests without result checking. It is useful for:

0 commit comments

Comments
 (0)