bobber6467 / python-nose

Automatically exported from code.google.com/p/python-nose
0 stars 0 forks source link

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

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 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 <module>
    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'

Original issue reported on code.google.com by praveen9...@gmail.com on 2 Aug 2011 at 7:21

GoogleCodeExporter commented 8 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= ?

Original comment by kumar.mcmillan on 2 Aug 2011 at 8:02

GoogleCodeExporter commented 8 years ago
Tim, do you have any ideas on this?

Original comment by kumar.mcmillan on 2 Aug 2011 at 8:03

GoogleCodeExporter commented 8 years ago
Which version of coverage do you use ?!

Original comment by timothee...@gmail.com on 2 Aug 2011 at 8:10

GoogleCodeExporter commented 8 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.

Original comment by praveen9...@gmail.com on 2 Aug 2011 at 8:15

GoogleCodeExporter commented 8 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.

Original comment by timothee...@gmail.com on 2 Aug 2011 at 8:59

Attachments:

GoogleCodeExporter commented 8 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

Original comment by praveen9...@gmail.com on 3 Aug 2011 at 4:39

GoogleCodeExporter commented 8 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 <module>
    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

Original comment by hiddenpy...@googlemail.com on 3 Aug 2011 at 10:10

GoogleCodeExporter commented 8 years ago
Are use using xcoverage here ?

Original comment by timothee...@gmail.com on 4 Aug 2011 at 7:58

GoogleCodeExporter commented 8 years ago
No, coverage only.

Original comment by hiddenpy...@googlemail.com on 4 Aug 2011 at 10:19

GoogleCodeExporter commented 8 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()

Original comment by timothee...@gmail.com on 4 Aug 2011 at 10:22

GoogleCodeExporter commented 8 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?

Original comment by hiddenpy...@googlemail.com on 4 Aug 2011 at 10:57