From 4d77653bb0155cab16cb995b34993ffb95e37c4b Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sun, 3 Jun 2012 21:06:43 +0200 Subject: [PATCH] simplify activate_funcargs --- _pytest/capture.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/_pytest/capture.py b/_pytest/capture.py index 221218266..b59e7b2a9 100644 --- a/_pytest/capture.py +++ b/_pytest/capture.py @@ -119,16 +119,12 @@ class CaptureManager: return "", "" def activate_funcargs(self, pyfuncitem): - if not hasattr(pyfuncitem, 'funcargs'): - return - assert not hasattr(self, '_capturing_funcarg') - capargs = [] - for name, capfuncarg in pyfuncitem.funcargs.items(): - if name in ('capsys', 'capfd'): - capargs.append(capfuncarg) - if capargs: - self._capturing_funcarg = capargs[0] - self._capturing_funcarg._start() + if hasattr(pyfuncitem, 'funcargs'): + for name, capfuncarg in pyfuncitem.funcargs.items(): + if name in ('capsys', 'capfd'): + assert not hasattr(self, '_capturing_funcarg') + self._capturing_funcarg = capfuncarg + capfuncarg._start() def deactivate_funcargs(self): capturing_funcarg = getattr(self, '_capturing_funcarg', None)