Ticket #119
--with-coverage not working with easy_installed Version of coverage
| Priority: | normal | Reporter: | chris@percious.com |
|---|---|---|---|
| Severity: | normal | Assigned to: | jpellerin |
| Component: | nose | Status: | new |
| Version: | Resolution: | ||
| Milestone: | Keywords: |
Description by chris@percious.com:
Mac OSX Python 2.4.4 Nose-0.10.0b1 Coverage-2.77
nosetests works just fine
nosetests --with-coverage breaks like this:
Traceback (most recent call last):
File "/usr/local//bin/nosetests", line 7, in ?
sys.exit(
File "/usr/local/lib/python2.4/site-packages/nose-0.10.0b1-py2.4.egg/nose/core.py", line 188, in init
argv=argv, testRunner=testRunner, testLoader=testLoader)
File "/usr/local/lib/python2.4/unittest.py", line 758, in init
self.parseArgs(argv)
File "/usr/local/lib/python2.4/site-packages/nose-0.10.0b1-py2.4.egg/nose/core.py", line 203, in parseArgs
self.config.configure(argv, doc=TestProgram?.doc)
File "/usr/local/lib/python2.4/site-packages/nose-0.10.0b1-py2.4.egg/nose/config.py", line 170, in configure
self.plugins.configure(options, self)
File "/usr/local/lib/python2.4/site-packages/nose-0.10.0b1-py2.4.egg/nose/plugins/manager.py", line 201, in configure
cfg(options, config)
File "/usr/local/lib/python2.4/site-packages/nose-0.10.0b1-py2.4.egg/nose/plugins/manager.py", line 79, in call
return self.call(*arg, **kw)
File "/usr/local/lib/python2.4/site-packages/nose-0.10.0b1-py2.4.egg/nose/plugins/manager.py", line 135, in simple
result = meth(*arg, **kw)
File "/usr/local/lib/python2.4/site-packages/nose-0.10.0b1-py2.4.egg/nose/plugins/cover.py", line 66, in configure
import coverage
File "/usr/local/bin/coverage.py", line 5, in ?
pkg_resources.run_script('coverage==2.77', 'coverage.py')
File "/usr/local/lib/python2.4/site-packages/setuptools-0.6c7-py2.4.egg/pkg_resources.py", line 448, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/local/lib/python2.4/site-packages/setuptools-0.6c7-py2.4.egg/pkg_resources.py", line 1166, in run_script
execfile(script_filename, namespace, namespace)
File "/usr/local/lib/python2.4/site-packages/coverage-2.77-py2.4.egg/EGG-INFO/scripts/coverage.py", line 8, in ?
coverage.the_coverage.command_line(sys.argv[1:]) AttributeError?: 'module' object has no attribute 'the_coverage'
let me know if you need any more info.
chris chris@percious.com
Attachments
Changelog
Mon Oct 1 06:21:24 2007: Modified by stephenemslie@gmail.com
Mon Oct 1 06:54:54 2007: Modified by stephenemslie@gmail.com
- attachment added: coverage-2.77-setuptools.patch

I'm seeing the same thing with coverage 2.77 (installed via easy_install) and nose 0.10.0a1
The main script appears to run a second script in coverage-2.77-py2.5.egg/EGG-INFO/scripts which then starts coverage. Except that the second script ends up importing itself despite an attempt to avoid that with.
del sys.path[0]
Installing with easy_install and running with nose produces the error, also then running coverage stand-alone does the same. Downloading the source and installing without setuptools still produces the error on nose, but not stand-alone. That makes sense because nose imports coverage before the coverage script gets its chance to play with sys.path (is this a good thing to do, anyway?).
So there's a quick (hacky) fix. Just delete the coverage script from /usr/bin (or equivalent) and nose will import the correct one first time :)
This could be better solved in coverage by using a setuptools style script. The setuptools docs on script creation describe this.