<br><br><div class="gmail_quote">On Mon, Oct 22, 2012 at 9:57 AM, Laurens Van Houtven <span dir="ltr"><<a href="mailto:_@lvh.cc" target="_blank">_@lvh.cc</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So, mock does have an autospec mode, which is not the default, but does result in eg methods undefined on the parent raising AttributeError.<br></blockquote><div><br></div><div>It does, but it won't for instance know that for:</div>
<div> mock_agent = mock.Mock(Agent)</div><div><br></div><div>that mock_agent.request should return a thing that looks like a Deferred. So you still</div><div>end up with a bunch of setup code to enforce return types and things.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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.<br>
</blockquote><div><br></div><div>Yeah, this doesn't work at all. You end up having to always pass a thing which provides the interface. Or an unspecified Mock.</div><div><br></div><div>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.</div>
<div><br></div><div>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. </div>
<div><br></div><div>-David</div></div><br>