<div dir="ltr"><div>The below issue was resolved (thanks to akerr on IRC).<br>It seems called_once_with is not a function of mock and doesn't work properly<br></div>Need to use assertTrue(mock_func.called) and thats working for me.<br>
<br>thanx,<br>deepak<br><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 3, 2014 at 9:46 PM, Deepak Shetty <span dir="ltr"><<a href="mailto:dpkshetty@gmail.com" target="_blank">dpkshetty@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><deepakcs> Hi, whats the right way to mock the LOG variable inside the driver ? I am mocking mock.patch.object(glusterfs, 'LOG') as mock_logger<br>
<deepakcs> and then doing...<br>
<deepakcs> mock_logger.warning.assert_called_once() - which passes and is expected to pass per my code<br><deepakcs> but<br><deepakcs> mock_logger.debug.assert_called_once() - shud fail , but this also passes !<br>
<deepakcs> any idea why ?<br><br></div>I feel that I am not mocking the LOG inside the driver correctly.<br><br>I also tried<br> mock.patch.object(glusterfs.LOG, 'warning'),<br> mock.patch.object(glusterfs.LOG, 'debug')<br>
</div>as mock_logger_warn and mock_logger_debug respectively<br><br></div>But here too<br></div>.debug and .warning both passes.. while the expected result is for .warning to pass and .debug to fail<br><br></div>So somehow I am unable to mock LOG properly<br>
<br>thanx,<br>deepak<br></div>
</blockquote></div><br></div></div></div></div>