[TIP] After upgrade to coverage 3.0.1, nosetests --with-coverage shows zero lines covered!
Ned Batchelder
ned at nedbatchelder.com
Sun Aug 9 17:23:45 PDT 2009
I've finally checked in a fix for this problem. It's a long story, and
I can share the details if you really want, but it boils down to a
module that TurboGears uses called DecoratorTools. This module is too
clever by half, and ends up trashing the trace function that coverage
needs to measure the code.
The fix involves a new mode for coverage.py, enabled with the --timid
switch, which makes coverage use a simpler and slower trace function.
This trace function isn't clobbered by DecoratorTools, so the code is
properly measured. For use with nosetests, you can set an environment
variable COVERAGE_OPTIONS to --timid also.
I haven't cut a new release yet, but you can use the tip of coverage.py
(http://bitbucket.org/ned/coveragepy/downloads/) for now.
--Ned.
http://nedbatchelder.com
Doug Latornell wrote:
> Thanks for the suggestions, Ned. I confirmed that the problem exists
> in a minimal TG 1.0.5 project:
>
> alec:coverage-test$ tg-admin quickstart spam
> ...
> alec:coverage-test$ cd spam/
> alec:spam$ nosetests --with-coverage --cover-package=spam --cover-erase
> ..
> Name Stmts Exec Cover Missing
> ------------------------------------------------
> spam 1 1 100%
> spam.config 1 1 100%
> spam.controllers 7 0 0% 1-13
> spam.templates 1 1 100%
> ------------------------------------------------
> TOTAL 10 3 30%
> ----------------------------------------------------------------------
> Ran 2 tests in 1.492s
>
> OK
> alec:spam$ sudo easy_install "coverage==2.85"
> ...
> alec:spam$ nosetests --with-coverage --cover-package=spam --cover-erase
> ..
> Name Stmts Exec Cover Missing
> ------------------------------------------------
> spam 0 0 100%
> spam.config 0 0 100%
> spam.controllers 7 7 100%
> spam.templates 0 0 100%
> ------------------------------------------------
> TOTAL 7 7 100%
> ----------------------------------------------------------------------
> Ran 2 tests in 9.206s
>
> OK
>
> Next, I'll try your -L option suggestion, and the logging from tip.
>
> Re: -L is there a way to pass a switch to coverage through the nose
> plug-in? AFAIK, the TG quickstart project template relies on nose for
> test discovery. The test module has nothing like a unittest.main()
> interface.
>
> Doug
>
>
> On Wed, Jul 15, 2009 at 6:34 PM, Ned Batchelder <ned at nedbatchelder.com
> <mailto:ned at nedbatchelder.com>> wrote:
>
> Doug, thanks for reporting this. If you don't get a toy TG
> project working, here are two things to try:
>
>
> ...
>
>
>
> --Ned.
> http://nedbatchelder.com
>
>
--
Ned Batchelder, http://nedbatchelder.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.idyll.org/pipermail/testing-in-python/attachments/20090809/7975ee0b/attachment.html
More information about the testing-in-python
mailing list