On 21/02/2019 06:55, Glyph wrote:
The methods being hooked don't necessarily return deferreds.
Glyph, this bit ^^^
I'd like it to be an explicit choice of the caller, ie:
result = yield SomeProtocol.onMessage.called()
# okay, we got here, we know onMessage was called,
# now we might want to tick a clock, or otherwise simulate
# async state manipulation.
# now I want to make sure the deferred chain on the onMessage result
has been completed:
yield result
I'm not sure I understand your example here.
Yeah, this is part of carly, that I posted earlier. It stems from the
need to get the results of method calls when you have no reference to
the object being calls, or sometimes a result that's a deferred you need
to wait on, particularly in a test, but have no way of doing so.
If you're feeling brave, have a read of:
https://github.com/cjw296/carly/blob/master/carly/hook.py
The assertion in question only happens if you call returnValue or do a
return with a Deferred directly; this example doesn't do either of
those things.
This is the test situation where I hit this issue:
https://github.com/cjw296/carly/blob/master/tests/test_untracked_deferred.py#L28-L35
I'd originally wanted to have that read:
@inlineCallbacks
def test1(self):
...
result = yield pita.asyncMethod.called()
with ShouldRaise(Exception(1)):
yield result
Now, which I'm actually happier with the end result here, I think the
above it legit, if unusual, and that assert trips it up.
cheers,
Chris
_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python