On Fri, Apr 17, 2009 at 03:26:37PM -0700, kochhar wrote: > Marius Gedminas wrote: > > On Fri, Apr 17, 2009 at 01:30:00PM -0700, kochhar wrote: > >> I'm trying to get statement-level code coverage numbers for my pylons > >> app while running tests outside of nose (user, integration and load > >> tests). I've tried using python-coverage and figleaf without success. > >> Neither tool seems to be able to track statements within my > >> application. python-coverage tells me that 0% of the lines in my app > >> were executed while figleaf only provides coverage numbers for the > >> standard library and Pylons library code. > >> > >> I ran coverage (from within my virtualenv) as: > >> $ source bin/activate > >> $ python bin/coverage.py -x bin/paster serve --reload development.ini > > > > bin/paster serve --reload spawns a subprocess. Python's coverage tools > > have no way of tracing code executed in a subprocess. > > > > Try bin/paster serve without --reload. > > Somewhat better success, the pylons framework code is tracked pretty well, > but > my controllers and other utilities I use are still reported at 0%. Can the > coverage tools trace code executed in a separate thread (such as workers and > background threads)?
A good question. Somehow I never encountered it. http://python.org/doc/current/library/sys.html#sys.settrace (upon which all Python coverage tools are based, I believe) says that the tracer function is thread-local. There ought to be a way to ask paster to run single-threaded. I think I read somewhere in the Pylons docs that --reload implies that, but it's unsuitable for your purposes for other reasons as you've already discovered. Perhaps a different approach might be simpler? There's middleware for profiling (e.g. repoze.profile) that profiles all the requests and provides a summary report at the end. It should not be too difficult to use that as a model and write some WSGI middleware for coverage analysis. Marius Gedminas -- Your eyes are weary from staring at the CRT. You feel sleepy. Notice how restful it is to watch the cursor blink. Close your eyes. The opinions stated above are yours. You cannot imagine why you ever felt otherwise.
signature.asc
Description: Digital signature
