diff --git a/CHANGELOG b/CHANGELOG index ebdb57e4b..8fca5f9ad 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -Changes between 1.3.1 and 1.3.x +Changes between 1.3.1 and 1.3.2a ================================================== New features @@ -56,6 +56,8 @@ Bug fixes / Maintenance - make path.bestrelpath(path) return ".", note that when calling X.bestrelpath the assumption is that X is a directory. - make initial conftest discovery ignore "--" prefixed arguments +- fix resultlog plugin when used in an multicpu/multihost xdist situation + (thanks Jakub Gustak) Changes between 1.3.0 and 1.3.1 ================================================== diff --git a/py/_plugin/pytest_resultlog.py b/py/_plugin/pytest_resultlog.py index 6763ebfd0..f16d5f73a 100644 --- a/py/_plugin/pytest_resultlog.py +++ b/py/_plugin/pytest_resultlog.py @@ -16,7 +16,8 @@ def pytest_addoption(parser): def pytest_configure(config): resultlog = config.option.resultlog - if resultlog: + # prevent opening resultlog on slave nodes (xdist) + if resultlog and not hasattr(config, 'slaveinput'): logfile = open(resultlog, 'w', 1) # line buffered config._resultlog = ResultLog(config, logfile) config.pluginmanager.register(config._resultlog) @@ -50,7 +51,7 @@ def generic_path(item): gpath.append(name) fspath = newfspath return ''.join(gpath) - + class ResultLog(object): def __init__(self, config, logfile): self.config = config diff --git a/testing/plugin/test_pytest_resultlog.py b/testing/plugin/test_pytest_resultlog.py index 7d41947d2..1585d366d 100644 --- a/testing/plugin/test_pytest_resultlog.py +++ b/testing/plugin/test_pytest_resultlog.py @@ -1,6 +1,7 @@ import py import os -from py._plugin.pytest_resultlog import generic_path, ResultLog +from py._plugin.pytest_resultlog import generic_path, ResultLog, \ + pytest_configure, pytest_unconfigure from py._test.collect import Node, Item, FSCollector def test_generic_path(testdir): @@ -172,4 +173,19 @@ def test_generic(testdir, LineMatcher): "x *:test_xfail", "x *:test_xfail_norun", ]) - + +def test_no_resultlog_on_slaves(testdir): + config = testdir.parseconfig("-p", "resultlog", "--resultlog=resultlog") + + assert not hasattr(config, '_resultlog') + pytest_configure(config) + assert hasattr(config, '_resultlog') + pytest_unconfigure(config) + assert not hasattr(config, '_resultlog') + + config.slaveinput = {} + pytest_configure(config) + assert not hasattr(config, '_resultlog') + pytest_unconfigure(config) + assert not hasattr(config, '_resultlog') +