Created
July 2, 2010 09:33
-
-
Save jlg/461155 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff -r 6005a1fe1408 py/_plugin/pytest_resultlog.py | |
| --- a/py/_plugin/pytest_resultlog.py Fri Jun 25 10:30:15 2010 +0200 | |
| +++ b/py/_plugin/pytest_resultlog.py Fri Jul 02 10:37:45 2010 +0000 | |
| @@ -16,7 +16,8 @@ | |
| 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 @@ | |
| gpath.append(name) | |
| fspath = newfspath | |
| return ''.join(gpath) | |
| - | |
| + | |
| class ResultLog(object): | |
| def __init__(self, config, logfile): | |
| self.config = config | |
| diff -r 6005a1fe1408 testing/plugin/test_pytest_resultlog.py | |
| --- a/testing/plugin/test_pytest_resultlog.py Fri Jun 25 10:30:15 2010 +0200 | |
| +++ b/testing/plugin/test_pytest_resultlog.py Fri Jul 02 10:37:45 2010 +0000 | |
| @@ -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 @@ | |
| "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') | |
| + |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment