more or less fixes #4 along with changeset e07b15140498

note that i don't understand why the twisted plugin went
through the "wrapper" function.  seems to work just
fine for me without it.  also added the "True"
return value which indicates we handled the call.
however, the plugin hook will need some refinments.
see XXXs.

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-04-17 19:33:38 +02:00
parent 2fd437e465
commit 3a9d2873b5
1 changed files with 7 additions and 12 deletions

View File

@ -100,18 +100,13 @@ class TwistedPlugin:
def pytest_pyfunc_call(self, pyfuncitem, *args, **kwargs):
if self.twisted:
def wrapper(func):
"""
wrapper just to pass back (injecting) the test-function into
doit() by using a greenlet switch.
"""
if hasattr(func, 'obj'):
# XXX: what about **kwargs?
res = gr_twisted.switch(lambda: func.obj(*args))
if res:
res.raiseException()
pyfuncitem = wrapper(pyfuncitem)
# XXX1 kwargs?
# XXX2 we want to delegate actual call to next plugin
# (which may want to produce test coverage, etc.)
res = gr_twisted.switch(lambda: pyfuncitem.obj(*args))
if res:
res.raiseException()
return True # indicates that we performed the function call
gr_twisted = greenlet(_run_twisted)
gr_tests = greenlet.getcurrent()