<div dir="ltr">On Thu, Jul 25, 2013 at 3:25 PM, James Broadhead <span dir="ltr"><<a href="mailto:jamesbroadhead@gmail.com" target="_blank">jamesbroadhead@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I very quickly ran into a problem where I mistakenly returned a Mock() in the place of a deferred, causing the asserts in callbacks to not be called, and for the test to spuriously pass.<br>
<br>A slightly more believable example:<br>== myclass.py ==<br>def some_function(...):<br>  d = self.authenticate()<br>


  d.addCallback(foo) # foo never called<br>  d.addErrback(bar) # bar never called<br>  return d<br><br>== test_myclass.py ==<br>def setUp(self):<br>  self.resource.authenticate = Mock(return_value=Mock())<br><br></div></div>
</blockquote><div><br></div><div>Why not use patch and replace it with lambda: defer.succeed(None)?</div><div><br></div><div>jml <br></div></div></div></div>