simplify activate_funcargs

This commit is contained in:
holger krekel 2012-06-03 21:06:43 +02:00
parent 3f17784386
commit 4d77653bb0
1 changed files with 6 additions and 10 deletions

View File

@ -119,16 +119,12 @@ class CaptureManager:
return "", "" return "", ""
def activate_funcargs(self, pyfuncitem): def activate_funcargs(self, pyfuncitem):
if not hasattr(pyfuncitem, 'funcargs'): if hasattr(pyfuncitem, 'funcargs'):
return
assert not hasattr(self, '_capturing_funcarg')
capargs = []
for name, capfuncarg in pyfuncitem.funcargs.items(): for name, capfuncarg in pyfuncitem.funcargs.items():
if name in ('capsys', 'capfd'): if name in ('capsys', 'capfd'):
capargs.append(capfuncarg) assert not hasattr(self, '_capturing_funcarg')
if capargs: self._capturing_funcarg = capfuncarg
self._capturing_funcarg = capargs[0] capfuncarg._start()
self._capturing_funcarg._start()
def deactivate_funcargs(self): def deactivate_funcargs(self):
capturing_funcarg = getattr(self, '_capturing_funcarg', None) capturing_funcarg = getattr(self, '_capturing_funcarg', None)