fix issue93 - hide output of code in early-loaded conftest files

--HG--
branch : trunk
This commit is contained in:
holger krekel
2010-10-24 23:26:14 +02:00
parent f466d35771
commit b4210f3ae0
4 changed files with 28 additions and 5 deletions

View File

@@ -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']

View File

@@ -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):