bobber6467 / python-nose

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

Error in addFailure when handling a pymox exception #405

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When using nose 1.0.0 (as well as trunk) I get the following nose error when my 
test fails due to a pymox exception:

======================================================================
ERROR: test_login (bamboo.tests.test_account_manager.TestAccountManager)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/skrul/dev/bamboo-env/lib/python2.6/site-packages/nose-1.0.1.dev-py2.6.egg/nose/case.py", line 133, in run
    self.runTest(result)
  File "/Users/skrul/dev/bamboo-env/lib/python2.6/site-packages/nose-1.0.1.dev-py2.6.egg/nose/case.py", line 151, in runTest
    test(result)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py", line 300, in __call__
    return self.run(*args, **kwds)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py", line 282, in run
    result.addFailure(self, self._exc_info())
  File "/Users/skrul/dev/bamboo-env/lib/python2.6/site-packages/nose-1.0.1.dev-py2.6.egg/nose/proxy.py", line 140, in addFailure
    #    err = (err[0], err[0](err[1]), err[2])
TypeError: __init__() takes exactly 3 arguments (2 given)
-------------------- >> begin captured logging << --------------------
pylons.configuration: DEBUG: Initializing configuration, package: 'bamboo'
routes.middleware: DEBUG: Initialized with method overriding = True, and path 
info altering = True
--------------------- >> end captured logging << ---------------------

In the debugger, err is:

(Pdb) print err
(<class 'mox.UnexpectedMethodCallError'>, "Unexpected method call 
Service.get_profile() -> None\n>>  raise UnexpectedMethodCallError(self, 
None)\n    \n-------------------- >> begin captured logging << 
--------------------\npylons.configuration: DEBUG: Initializing configuration, 
package: 'bamboo'\nroutes.middleware: DEBUG: Initialized with method overriding 
= True, and path info altering = True\n--------------------- >> end captured 
logging << ---------------------", <traceback object at 0x10488c638>)

I am able to get this to work as it should by removing the two lines of code 
added to proxy.py in this change:

http://code.google.com/p/python-nose/source/detail?r=5469e307c15d0fecf3e661c3564
e11e8a2320cdf

Original issue reported on code.google.com by skrulx on 21 Mar 2011 at 9:32

GoogleCodeExporter commented 8 years ago
Oh wow!  You found the easter egg in our Python 3 implementation :( This is 
tricky because Nose plugins do all sorts of things to exception tuples before 
sending them to the result and as of Python 3, result.addFailure requires an 
exception instance not a string.  I couldn't think of a nice fix but I was able 
to make things less broken.

Fixed in rev b3cdbd839e78 and scheduled for 1.0.1.  Thanks for the bug.

Original comment by kumar.mcmillan on 22 Mar 2011 at 3:06

GoogleCodeExporter commented 8 years ago
This change works great -- many thanks for the quick fix!

Original comment by skrulx on 22 Mar 2011 at 4:40