diff --git a/pytest/__init__.py b/pytest/__init__.py index 3ded672c1..19bde72c5 100644 --- a/pytest/__init__.py +++ b/pytest/__init__.py @@ -5,7 +5,7 @@ see http://pytest.org for documentation and details (c) Holger Krekel and others, 2004-2010 """ -__version__ = "2.0.0.dev4" +__version__ = '2.0.0.dev6' __all__ = ['config', 'cmdline'] diff --git a/pytest/plugin/config.py b/pytest/plugin/config.py index 89433a4d2..619e84983 100644 --- a/pytest/plugin/config.py +++ b/pytest/plugin/config.py @@ -3,6 +3,7 @@ import py import sys, os from pytest._core import PluginManager + def pytest_cmdline_parse(pluginmanager, args): config = Config(pluginmanager) config.parse(args) @@ -283,11 +284,25 @@ class Config(object): if not hasattr(self.option, opt.dest): setattr(self.option, opt.dest, opt.default) + def _setinitialconftest(self, args): + # capture output during conftest init (#issue93) + name = hasattr(os, 'dup') and 'StdCaptureFD' or 'StdCapture' + cap = getattr(py.io, name)() + try: + try: + self._conftest.setinitial(args) + finally: + out, err = cap.reset() + except: + sys.stdout.write(out) + sys.stderr.write(err) + raise + def _preparse(self, args): self.pluginmanager.consider_setuptools_entrypoints() self.pluginmanager.consider_env() self.pluginmanager.consider_preparse(args) - self._conftest.setinitial(args) + self._setinitialconftest(args) self.pluginmanager.do_addoption(self._parser) def parse(self, args): diff --git a/setup.py b/setup.py index 1ddbf92fd..c6d19a7f8 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.0.0.dev5', + version='2.0.0.dev6', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 9e04ff7bf..c751dcfad 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -138,15 +138,23 @@ class TestGeneralUsage: "*Module*test_issue88*", ]) - @py.test.mark.xfail def test_issue93_initialnode_importing_capturing(self, testdir): testdir.makeconftest(""" - print "should not be seen" + print ("should not be seen") """) result = testdir.runpytest() assert result.ret == 0 assert "should not be seen" not in result.stdout.str() + def test_conftest_printing_shows_if_error(self, testdir): + testdir.makeconftest(""" + print ("should be seen") + assert 0 + """) + result = testdir.runpytest() + assert result.ret != 0 + assert "should be seen" in result.stdout.str() + @py.test.mark.skipif("not hasattr(os, 'symlink')") def test_chdir(self, testdir): testdir.tmpdir.join("py").mksymlinkto(py._pydir)