<div dir="ltr"><div>Hi Ian,<br><br>Thanks for your response. That&#39;s what I thought too. What you said makes sense and using an AST tree would probably end up finding some assert statement down the road (or if not, flag the test).<br><br></div><div>Such tool would definitely be handy test linting tool. I&#39;ll look around pypi otherwise I may take a stab at implementing it depending on my spare bandwidth.<br><br></div><div>Best,<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-14 10:51 GMT-08:00 Ian Cordasco <span dir="ltr">&lt;<a href="mailto:graffatcolmingov@gmail.com" target="_blank">graffatcolmingov@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Nov 14, 2014 at 12:00 PM, Alexandre Conrad<br>
&lt;<a href="mailto:alexandre.conrad@gmail.com">alexandre.conrad@gmail.com</a>&gt; wrote:<br>
&gt; Hi list,<br>
&gt;<br>
&gt; I was wondering if you knew a tool that would ensure that tests contain some<br>
&gt; kind of assertions e.g., an assert statement or a call to a method such as<br>
&gt; TestCase.assertTrue().<br>
&gt;<br>
&gt; I would love to be able to run something like &quot;py.test<br>
&gt; --fail-missing-assert&quot; which would fail a test if the user accidentally did<br>
&gt; &quot;data == expected_data&quot; rather than &quot;assert data == expected_data&quot;.<br>
&gt;<br>
&gt; Tests without any assertions are the worst because the number of tests and<br>
&gt; code coverage grows providing a false sense of satisfaction when really the<br>
&gt; test would have failed in the first place if a proper assertion was written.<br>
&gt;<br>
&gt; Any thoughts on this?<br>
&gt;<br>
&gt; Thanks,<br>
&gt; --<br>
&gt; Alex<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; testing-in-python mailing list<br>
&gt; <a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br>
&gt; <a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
&gt;<br>
<br>
Hey Alex,<br>
<br>
I don&#39;t know how practical this would be. You&#39;d essentially have to do<br>
a whole other pass over the code (either using static or AST analysis)<br>
to determine if an assertion wasn&#39;t made. The reason for this is that<br>
a lot of test suites write helper methods to try to DRY up their tests<br>
so a test may end with self.verifyFooBarBaz(some, params) which calls<br>
another method. Static analysis as a first pass would flag that test<br>
method, but using the AST you might be able to find the assertion...<br>
eventually.<br>
<br>
Cheers,<br>
Ian<br>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr">Alex</div></div>
</div>