On Mon, Oct 22, 2012 at 9:57 AM, Laurens Van Houtven <_...@lvh.cc> wrote:

> So, mock does have an autospec mode, which is not the default, but does
> result in eg methods undefined on the parent raising AttributeError.
>

It does, but it won't for instance know that for:
    mock_agent = mock.Mock(Agent)

that mock_agent.request should return a thing that looks like a Deferred.
 So you still
end up with a bunch of setup code to enforce return types and things.


> I don't know if there's a way to generate a mock from an interface:
> particularly the fact that interface methods don't have "self" in their
> signature might trip it up.
>

Yeah, this doesn't work at all.  You end up having to always pass a thing
which provides the interface.  Or an unspecified Mock.

Of course, this isn't actually a "verified" Mock.  Because you still have
to specify all the behavior and constructing that behavior by setting
side_effect and return_value is often difficult and confusing.

So though I use mock quite a bit in my personal projects and at work I am
definitely against using it for twisted style tests.  I'd rather see some
energy put into things like a verified fake Request object and a
ResourceTraversingAgent.

-David
_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to