Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'ContextSuite' has no attribute 'capturedOutput' in 0.10.3 #23

Open
jpellerin opened this issue Dec 14, 2011 · 4 comments
Assignees

Comments

@jpellerin
Copy link
Member

I came across the following issue with our custom output plugin for nose
when an Exception occurred when running setUp in a nose context suite:

Traceback (most recent call last):
File "/ws/garrcoop-sjc/tools/bin/nosetests", line 7, in ?
sys.exit(
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/core.py",
line 219, in init
argv=argv, testRunner=testRunner, testLoader=testLoader)
File "/ws/garrcoop-sjc/tools///lib/python2.4/unittest.py", line 759, in
init
self.runTests()
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/core.py",
line 298, in runTests
result = self.testRunner.run(self.test)
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/core.py",
line 62, in run
test(result)
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/suite.py",
line 132, in call
return self.run(_arg, *_kw)
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/suite.py",
line 162, in run
test(orig)
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/suite.py",
line 132, in call
return self.run(_arg, *_kw)
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/suite.py",
line 162, in run
test(orig)
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/suite.py",
line 132, in call
return self.run(_arg, *_kw)
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/suite.py",
line 162, in run
test(orig)
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/suite.py",
line 132, in call
return self.run(_arg, *_kw)
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/suite.py",
line 152, in run
result.addError(self, self.exc_info())
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/proxy.py",
line 120, in addError
plugins.addError(self.test, err)
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/plugins/manager.py",
line 81, in call
return self.call(_arg, *_kw)
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/plugins/manager.py",
line 145, in simple
result = meth(_arg, *_kw)
File
"/thumper/sanity/pynt/usr/lib/python2.4/site-packages/nose-0.10.3.p1-py2.4.egg/nose/plugins/manager.py",
line 303, in addError
capt = test.capturedOutput
AttributeError: 'ContextSuite' object has no attribute 'capturedOutput'

The attached patch fixed that issue, but it's odd why a ContextSuite is
being misinterpreted at this level...

Google Code Info:
Issue #: 296
Author: [email protected]
Created On: 2009-10-16T10:47:44.000Z
Closed On:

@ghost ghost assigned jpellerin Dec 14, 2011
@jpellerin
Copy link
Member Author

0.10.3 is a very old version. Can you verify that this bug still exists in the
current code in mercurial?

Google Code Info:
Author: [email protected]
Created On: 2009-10-16T14:04:22.000Z

@jpellerin
Copy link
Member Author

AttributeError: 'ContextSuite' object has no attribute 'capturedOutput'

We were getting the same error when using the teamcity-nose and teamcity-messages plugin. Using Python 2.6. Tested with the latest nose 1.0.0 on pypi, and tip at https://bitbucket.org/jpellerin/nose/ changeset 780: 6318b0c855a6
Get the error on both.

Fixed it a little differently than yanegomi. Patch attached. The code will still pass through the error data to the teamcity plugin, so that the error gets printed in the teamcity service message, and you will know what failed. nat_linden kindly made a fork from nose tip, with the patch here: https://bitbucket.org/nat_linden/nose/

thanks
automated.test.spider and nat_linden

Google Code Info:
Author: [email protected]
Created On: 2011-05-19T22:46:55.000Z

@jpellerin
Copy link
Member Author

whoops, this issue wasn't tagged with the patch so we lost track of it. Thanks for updating the patch.

If you can add a test that reproduces the error then it would greatly speed up getting the patch applied. There is info in DEVELOPERS.txt for how to run the tests.

Google Code Info:
Author: kumar.mcmillan
Created On: 2011-05-21T00:26:41.000Z

@jpellerin
Copy link
Member Author

Thanks Kumar. I believe the issue occurs when you have a nose plugin using the old plugin api (0.9) which goes through the ZeroNinePlugin code. The test script has a setup function, rather than a method of a unittest.TestCase subclass. If there is a failure during the setup function, the test object has no capturedOutput attribute, nor does it have a test attribute (test.test). I'll work on making a unit test case that simulates this condition.

If useful, here are some manual steps to reproduce:

  1. Create a virtualenv
    virtualenv --no-site-packages --distribute issue296
  2. Pip install the teamcity-nose package, which will install the teamcity-messages dependency, and nose. The TeamCity plugin is based on the older nose plugin api.
    issue296\Scripts\pip install teamcity-nose
  3. I like to install and run yolk in my virtualenv, to verify the packages and their versions (but this is not required for the test)
    issue296\Scripts\pip install yolk
    issue296\Scripts\yolk -l
  4. Make sure that the TEAMCITY_PROJECT_NAME environment variable is set with some value (any value). The teamcity-nose plugin checks for the environment variable to determine whether it should be active.
    SET TEAMCITY_PROJECT_NAME=foo
  5. Create a python script with test case functions that have a setup function that will fail. The setup and test case functions are NOT subclasses of unittest.TestCase. I named it break.py.

Test cases which are not subclasses of unittest.TestCase

with a setup function which will raise an Exception


def setup():
raise RuntimeError('break setup')

def test_one():
print "testone"

def test_two():

print "testtwo"

  1. Run the test script file via nosetests without -s.
    issue296\Scripts\nosetests issue296\break.py
    ##teamcity[testSuiteStarted name='break']
    Traceback (most recent call last):
    File "C:\natspider\issue296\Scripts\nosetests-script.py", line 9, in
    load_entry_point('nose==1.0.0', 'console_scripts', 'nosetests')()
    File "C:\natspider\issue296\lib\site-packages\nose\core.py", line 118, in init
    *_extra_args)
    File "C:\Python26\Lib\unittest.py", line 817, in init
    self.runTests()
    File "C:\natspider\issue296\lib\site-packages\nose\core.py", line 197, in runTests
    result = self.testRunner.run(self.test)
    File "C:\natspider\issue296\lib\site-packages\nose\core.py", line 61, in run
    test(result)
    File "C:\natspider\issue296\lib\site-packages\nose\suite.py", line 176, in call
    return self.run(_arg, *_kw)
    File "C:\natspider\issue296\lib\site-packages\nose\suite.py", line 213, in run
    result.addError(self, self._exc_info())
    File "C:\natspider\issue296\lib\site-packages\nose\proxy.py", line 124, in addError
    plugins.addError(self.test, err)
    File "C:\natspider\issue296\lib\site-packages\nose\plugins\manager.py", line 94, in call
    return self.call(_arg, *_kw)
    File "C:\natspider\issue296\lib\site-packages\nose\plugins\manager.py", line 162, in simple
    result = meth(_arg, *_kw)
    File "C:\natspider\issue296\lib\site-packages\nose\plugins\manager.py", line 320, in addError
    return self.plugin.addError(test.test, err, capt)
    AttributeError: 'ContextSuite' object has no attribute 'test'
  2. Run the test script file via nosetests with -s.
    issue296\Scripts\nosetests issue296\break.py
    ##teamcity[testSuiteStarted name='break']
    Traceback (most recent call last):
    File "C:\natspider\issue296\Scripts\nosetests-script.py", line 9, in
    load_entry_point('nose==1.0.0', 'console_scripts', 'nosetests')()
    File "C:\natspider\issue296\lib\site-packages\nose\core.py", line 118, in init
    *_extra_args)
    File "C:\Python26\Lib\unittest.py", line 817, in init
    self.runTests()
    File "C:\natspider\issue296\lib\site-packages\nose\core.py", line 197, in runTests
    result = self.testRunner.run(self.test)
    File "C:\natspider\issue296\lib\site-packages\nose\core.py", line 61, in run
    test(result)
    File "C:\natspider\issue296\lib\site-packages\nose\suite.py", line 176, in call
    return self.run(_arg, *_kw)
    File "C:\natspider\issue296\lib\site-packages\nose\suite.py", line 213, in run
    result.addError(self, self._exc_info())
    File "C:\natspider\issue296\lib\site-packages\nose\proxy.py", line 124, in addError
    plugins.addError(self.test, err)
    File "C:\natspider\issue296\lib\site-packages\nose\plugins\manager.py", line 94, in call
    return self.call(_arg, *_kw)
    File "C:\natspider\issue296\lib\site-packages\nose\plugins\manager.py", line 162, in simple
    result = meth(_arg, *_kw)
    File "C:\natspider\issue296\lib\site-packages\nose\plugins\manager.py", line 319, in addError
    capt = test.capturedOutput
    AttributeError: 'ContextSuite' object has no attribute 'capturedOutput'

Google Code Info:
Author: [email protected]
Created On: 2011-05-25T19:57:04.000Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant