[TIP] coverage.py has slightly different results when being called from setup.py and not...
ned at nedbatchelder.com
Sat Jan 28 10:42:04 PST 2017
Tom, I appreciate the work you put into investigation.
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.
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. 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.
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
I hope this doesn't come off as too bossy.. :)
On 1/28/17 12:36 PM, Tom Swirly wrote:
> Greetings, testy people. Thanks for this excellent package!
> 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.
> The project is quite vanilla and doesn't use any of the trouble
> techniques listed here:
> --timid had no effect.
> The issue: when I run coverage from setup.py
> <http://coverage%20run%20-m%20unittest%20discover%20test%20%5C*_test.py> this
> file gamma.py
> <https://github.com/ManiacalLabs/BiblioPixel/blob/dev/bibliopixel/gamma.py> is
> marked as having only 6% coverage - nothing except line 14
> I don't even see how that would be possible, but more, there's an
> explicit test that at least loads the file
> even if it doesn't test the values - and yes, I can see that test run
> in my results.
> If I run coverage.py from the command line, like this:
> coverage run -m unittest discover test \*_test.py .
> I see 100% coverage as expected.
> 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 this one
> is it...)
> Thanks in advance!
> http://radio.swirly.com - art music radio 24/7 366/1000
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python