nose-devs / nose

nose is nicer testing for python
http://readthedocs.org/docs/nose/en/latest/
1.36k stars 395 forks source link

Nose 1.1.2: Running nose with the coverage option results in Error #132

Open jpellerin opened 12 years ago

jpellerin commented 12 years ago

Hi! This is Praveen Kumar working with Melange on their testing project. Running the tests with the coverage option results in an AttributeError as shown in the following traceback. The tests run fine with the cover.py in nose 1.0.0. I am not familiar with nose code base otherwise I would have submitted a patch to fix this.

Traceback (most recent call last): File "bin/run-tests", line 42, in tests.run.main() File "/home/praveen/melangecopy/tests/run.py", line 174, in main nose.main(addplugins=plugins) File "/home/praveen/melangecopy/eggs/nose-1.1.2-py2.5.egg/nose/core.py", line 118, in init _extra_args) File "/usr/local/lib/python2.5/unittest.py", line 768, in init self.runTests() File "/home/praveen/melangecopy/eggs/nose-1.1.2-py2.5.egg/nose/core.py", line 197, in runTests result = self.testRunner.run(self.test) File "/home/praveen/melangecopy/eggs/nose-1.1.2-py2.5.egg/nose/core.py", line 63, in run result.printErrors() File "/home/praveen/melangecopy/eggs/nose-1.1.2-py2.5.egg/nose/result.py", line 110, in printErrors self.config.plugins.report(self.stream) File "/home/praveen/melangecopy/eggs/nose-1.1.2-py2.5.egg/nose/plugins/manager.py", line 94, in call return self.call(_arg, _kw) File "/home/praveen/melangecopy/eggs/nose-1.1.2-py2.5.egg/nose/plugins/manager.py", line 162, in simple result = meth(_arg, **kw) File "/home/praveen/melangecopy/eggs/nose-1.1.2-py2.5.egg/nose/plugins/cover.py", line 167, in report self.coverInstance.save() AttributeError: 'module' object has no attribute 'save'

Google Code Info: Issue #: 443 Author: praveen9...@gmail.com Created On: 2011-08-02T19:21:47.000Z Closed On:

jpellerin commented 12 years ago

Hm, it looks like you have a custom test runner. What code is in bin/run-tests and what plugins are in addplugins= ?

Google Code Info: Author: kumar.mcmillan Created On: 2011-08-02T20:02:10.000Z

jpellerin commented 12 years ago

Tim, do you have any ideas on this?

Google Code Info: Author: kumar.mcmillan Created On: 2011-08-02T20:03:46.000Z

jpellerin commented 12 years ago

Which version of coverage do you use ?!

Google Code Info: Author: timothee.peignier@gmail.com Created On: 2011-08-02T20:10:52.000Z

jpellerin commented 12 years ago

There is nothing much in bin/run-tests. bin/run-tests just adds some modules to the python path and calls the main() method in tests.run (http://code.google.com/p/soc/source/browse/tests/run.py). The plugin is to clear our Appengine datastore automatically after the completion of every test.

Google Code Info: Author: praveen9...@gmail.com Created On: 2011-08-02T20:15:20.000Z

jpellerin commented 12 years ago

It seems you are using an old version of coverage. I encourage you to use the latest version if you can. I made a fix to avoid this error when using old coverage module. But I think we should drop coverage < 3.0.

Google Code Info: Author: timothee.peignier@gmail.com Created On: 2011-08-02T20:59:37.000Z

jpellerin commented 12 years ago

Thanks for the help Tim. We were using coverage 2.85 which was added to our testing system 2 years back and was not updated afterwards. We will be now switching to the latest one i.e. coverage 3.5. Thanks once again.

Praveen

Google Code Info: Author: praveen9...@gmail.com Created On: 2011-08-03T16:39:23.000Z

jpellerin commented 12 years ago

It seems that coverage 3.5 doesn't work, either :-). I got the following error instead. It looks like the same problem [0] appeared again. Any ideas? Thanks in advance.

[0] https://github.com/cmheisel/nose-xcover/pull/7

Traceback (most recent call last): File "bin/run-tests", line 43, in tests.run.main() File "/Users/Tiger/Src/Projects/melange/experimental2/hg/tests/run.py", line 174, in main nose.main(addplugins=plugins) File "/Users/Tiger/Src/Projects/melange/experimental2/hg/eggs/nose-1.1.2-py2.5.egg/nose/core.py", line 118, in init _extra_args) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/unittest.py", line 768, in init self.runTests() File "/Users/Tiger/Src/Projects/melange/experimental2/hg/eggs/nose-1.1.2-py2.5.egg/nose/core.py", line 197, in runTests result = self.testRunner.run(self.test) File "/Users/Tiger/Src/Projects/melange/experimental2/hg/eggs/nose-1.1.2-py2.5.egg/nose/core.py", line 63, in run result.printErrors() File "/Users/Tiger/Src/Projects/melange/experimental2/hg/eggs/nose-1.1.2-py2.5.egg/nose/result.py", line 110, in printErrors self.config.plugins.report(self.stream) File "/Users/Tiger/Src/Projects/melange/experimental2/hg/eggs/nose-1.1.2-py2.5.egg/nose/plugins/manager.py", line 94, in call return self.call(_arg, _kw) File "/Users/Tiger/Src/Projects/melange/experimental2/hg/eggs/nose-1.1.2-py2.5.egg/nose/plugins/manager.py", line 162, in simple result = meth(_arg, **kw) File "/Users/Tiger/Src/Projects/melange/experimental2/hg/eggs/nose-1.1.2-py2.5.egg/nose/plugins/cover.py", line 166, in report self.coverInstance.stop() File "/Users/Tiger/Src/Projects/melange/experimental2/hg/thirdparty/coverage/coverage/control.py", line 387, in stop self.collector.stop() File "/Users/Tiger/Src/Projects/melange/experimental2/hg/thirdparty/coverage/coverage/collector.py", line 246, in stop assert self._collectors[-1] is self AssertionError Exception exceptions.AttributeError: "'NoneType' object has no attribute 'path'" in <bound method Signal._remove_receiver of <django.dispatch.dispatcher.Signal object at 0x20eeb30>> ignored

Google Code Info: Author: hiddenpy...@gmail.com Created On: 2011-08-03T22:10:40.000Z

jpellerin commented 12 years ago

Are use using xcoverage here ?

Google Code Info: Author: timothee.peignier@gmail.com Created On: 2011-08-04T07:58:17.000Z

jpellerin commented 12 years ago

No, coverage only.

Google Code Info: Author: hiddenpy...@gmail.com Created On: 2011-08-04T10:19:22.000Z

jpellerin commented 12 years ago

There is two coverage instance initialized here, it's not a bug in nose. You should try to remove those two line in melange run.py :

from nose.plugins import cover
plugin = cover.Coverage()

Google Code Info: Author: timothee.peignier@gmail.com Created On: 2011-08-04T10:22:28.000Z

jpellerin commented 12 years ago

Hi Tim, thanks a lot for your suggestion.

There is, however, only one coverage instance initialized here. Where is the other one :-)? Does nose initialize another instance automatically instead of reusing the one in plugins?

Google Code Info: Author: hiddenpy...@gmail.com Created On: 2011-08-04T10:57:53.000Z