<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 28 January 2017 at 19:42, Ned Batchelder <span dir="ltr"><<a href="mailto:ned@nedbatchelder.com" target="_blank">ned@nedbatchelder.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<p>Tom, I appreciate the work you put into investigation. </p></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
<p>The reason gamma.py only marks line 14 as covered is because the
rest of the file is executed before you start measuring coverage.
Setup.py imports bibliopixel/__init__.py, which imports gamma.py,
which executes all of the lines in the file except for line 14.
Then setup.py starts coverage, and then your tests run, executing
line 14.</p>
<p>You are doing a few things you perhaps should not. Importing
your product code into setup.py can be dangerous, because it might
mean you need your requirements before you've had a chance to
install your requirements. </p></div></blockquote><div>Ugh, you are so right. So obvious in hindsight.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><p>You have no requirements, so you don't
have this problem, but many projects go to great lengths to avoid
importing the product code into setup.py for this reason. If you
didn't import it, your coverage issue would be solved.</p></div></blockquote><div>DOH. :-D</div><div><br>Why was this not obvious to me? In hindsight, that was the only possible reason for the observed behavior. Well, I can fix this in seconds.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
<p>Another unusual thing here is using setup.py to run tests.
Although the distutils docs describe this possibility, most
projects don't do it. They use setup.py for distribution work
(building and installing kits), but not for other development
tasks. You have a tox.ini, but are only using it to configure
flake8! That is very unusual. Use tox to run your tests.</p></div></blockquote><div>While I didn't actually set this part up, there's a default "test" target in setuptools, and all sorts of machinery to run tests - so that's sort of a trap, certainly an <a href="https://en.wikipedia.org/wiki/Attractive_nuisance_doctrine">attractive nuisance</a> if nothing else!</div><div><br></div><div>I'll confer with the other maintainer/original author of this project and see what he thinks. My theory is he might not want to change it if it's not hurting anything.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
<p>I hope this doesn't come off as too bossy.. :)</p></div></blockquote><div>Oh, you must be joking - a solution to my problem and carefully worked-out reasoning as to why? Learning something about packaging from a master? You can be "bossy" like that any day as far as I'm concerned!</div><div><br></div><div>If you're ever in Amsterdam, drop by and I'll purchase you a refreshing beverage or two of your choice. :-)</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
<p>--Ned.<br>
</p><div><div class="h5">
<br>
<div class="m_-5203907426897437826moz-cite-prefix">On 1/28/17 12:36 PM, Tom Swirly wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div class="h5">
<div dir="ltr">Greetings, testy people. Thanks for this excellent
package!
<div><br>
<div><br>
</div>
<div>I discovered coverage.py last week and have been dropping
it into various projects I'm on. One of them only has a
strangeness and I'd like to figure it out.</div>
<div><br>
</div>
<div>The project is quite vanilla and doesn't use any of the
trouble techniques listed here: <a href="https://coverage.readthedocs.io/en/coverage-4.3.4/trouble.html" target="_blank">https://coverage.readthedocs.<wbr>io/en/coverage-4.3.4/trouble.<wbr>html</a>
</div>
<div><br>
</div>
<div>
<div>--timid had no effect.</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>The issue: when I run coverage <a href="http://coverage%20run%20-m%20unittest%20discover%20test%20%5C*_test.py" target="_blank">from
setup.py</a> this file <a href="https://github.com/ManiacalLabs/BiblioPixel/blob/dev/bibliopixel/gamma.py" target="_blank">gamma.py</a> is
marked as having only 6% coverage - nothing except line <a href="https://github.com/ManiacalLabs/BiblioPixel/blob/dev/bibliopixel/gamma.py#L14" target="_blank">14</a>.
</div>
<div><br>
</div>
<div>I don't even see how that would be possible, but more,
there's an explicit test that at least <a href="https://github.com/ManiacalLabs/BiblioPixel/blob/dev/test/gamma_test.py" target="_blank">loads
the file</a>, even if it doesn't test the values - and
yes, I can see that test run in my results.<br>
</div>
</div>
<div>
<div><br>
</div>
<div>
<div>If I run coverage.py from the command line, like this:</div>
<div><br>
</div>
</div>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><font face="monospace,
monospace">coverage run -m unittest discover test
\*_test.py .</font></blockquote>
<div><br>
</div>
<div> I see 100% coverage as expected. </div>
</div>
<div><br>
</div>
<div>
<div><br>
</div>
<div><br>
</div>
<div>Generally, I hate hitting up mailing lists until I have
had a chance to debug the package I'm whining about ;-), but
in this case I'm really not quite sure how to debug
coverage.py, and I see no bug report I can camp on. (I
don't think <a href="https://bitbucket.org/ned/coveragepy/issues/280/allow-test-suite-run-via-python-setuppy" target="_blank">this
one</a> is it...)</div>
<div><br>
</div>
<div>Thanks in advance!</div>
<div>
<div><br>
</div>
-- <br>
<div class="m_-5203907426897437826gmail_signature"> /t<br>
<br>
<a href="http://radio.swirly.com" target="_blank">http://radio.swirly.com</a> - art music
radio 24/7 366/1000</div>
</div>
</div>
</div>
<br>
<fieldset class="m_-5203907426897437826mimeAttachmentHeader"></fieldset>
<br>
</div></div><pre>______________________________<wbr>_________________
testing-in-python mailing list
<a class="m_-5203907426897437826moz-txt-link-abbreviated" href="mailto:testing-in-python@lists.idyll.org" target="_blank">testing-in-python@lists.idyll.<wbr>org</a>
<a class="m_-5203907426897437826moz-txt-link-freetext" href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/<wbr>listinfo/testing-in-python</a>
</pre>
</blockquote>
<br>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"> /t<br><br><a href="http://radio.swirly.com" target="_blank">http://radio.swirly.com</a> - art music radio 24/7 366/1000</div>
</div></div>