<div dir="ltr">I think that functional tests are fine, but they don&#39;t replace microtests.<div>Microtests are fine, too but they don&#39;t replace functional tests.<br>Both of those are great, but don&#39;t replace humans when it comes to matters of taste, experience, and judgment. ;-)</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, May 9, 2017 at 9:35 AM Tim Ottinger &lt;<a href="mailto:tottinge@gmail.com">tottinge@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Assuming you are doing a unit test (aka microtest):<br><br>One easy way to avoid file system dependencies is to separate out a function that opens the file you specify.<div>It becomes a very trivial function, of course.</div><div><br>In the test, you stub that function to return a file-like object of the fake content you need in order for the test to work. <br>This works just fine whether reading or writing.<div><br></div><div>Of course, if you want to fake a higher level, you can split out a function that opens the file and parses the data -- then mock that function out. <br><br>If nothing else is easy/quick/handy, you can always extract and mock your way out of (nearly) any situation.<div><br></div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, May 9, 2017 at 8:34 AM Gregory Salvan &lt;<a href="mailto:apieum@gmail.com" target="_blank">apieum@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>I&#39;m not advocating against functionnal tests in my answer, but if you want my opinion about them it&#39;s best explained here: <a href="http://blog.thecodewhisperer.com/permalink/integrated-tests-are-a-scam" target="_blank">http://blog.thecodewhisperer.com/permalink/integrated-tests-are-a-scam</a><br><br></div>Then I&#39;ve answered for TDD and BDD and not for real live system, the purpose is different. By the way if you have cases where it&#39;s relevant to test open() in real live system, I&#39;m curious.<br></div>Once you&#39;ve tested open() is called correctly (by injecting a mock of open()) what&#39;s the point to test if it works in a real live system otherwise testing if open() implementation works correctly?<br></div><div class="gmail_extra"><br><div class="gmail_quote">2017-05-09 14:31 GMT+02:00 Matt Wheeler <span dir="ltr">&lt;<a href="mailto:m@funkyhat.org" target="_blank">m@funkyhat.org</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span><div class="gmail_quote"><div dir="ltr">On Tue, 9 May 2017, 11:50 Gregory Salvan, &lt;<a href="mailto:apieum@gmail.com" target="_blank">apieum@gmail.com</a>&gt; wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It&#39;s to generic to have complex examples, but you really can test everything without writing data in files, and it&#39;s not really relevant to test if data are really written as it&#39;s the same as testing if there&#39;s no errors in python &quot;open&quot; implementation. I think we can trust python developpers for that ;)</div></blockquote></div><div><br></div></span><div>No, it&#39;s not just testing that open() works correctly, it&#39;s also testing that it&#39;s being called correctly in a real* live system. You seem to be advocating against functional tests as a concept?</div><div><br></div><div>*certainly more real than a system involving mocking open() in a unit test.</div><span class="m_-7072913198179969732m_-2361777801764051398HOEnZb"><font color="#888888"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></font></span></div><span class="m_-7072913198179969732m_-2361777801764051398HOEnZb"><font color="#888888"><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr"><p dir="ltr">--<br>
Matt Wheeler<br>
<a href="http://funkyh.at" target="_blank">http://funkyh.at</a></p>
</div></div>
</font></span></blockquote></div><br></div>
_______________________________________________<br>
testing-in-python mailing list<br>
<a href="mailto:testing-in-python@lists.idyll.org" target="_blank">testing-in-python@lists.idyll.org</a><br>
<a href="http://lists.idyll.org/listinfo/testing-in-python" rel="noreferrer" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
</blockquote></div></blockquote></div>