bobber6467 / python-nose

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

Capture plugin with python 3 #442

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. run a test which print some text on standard output then fails
2. stacktrace from test is display but not output, instead we get the following 
stacktrace :
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.1/dist-packages/nose-1.1.2-py3.1.egg/nose/case.py", line 134, in run
    self.runTest(result)
  File "/usr/local/lib/python3.1/dist-packages/nose-1.1.2-py3.1.egg/nose/case.py", line 152, in runTest
    test(result)
  File "/usr/lib/python3.1/unittest.py", line 526, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib/python3.1/unittest.py", line 490, in run
    result.addError(self, sys.exc_info())
  File "/usr/local/lib/python3.1/dist-packages/nose-1.1.2-py3.1.egg/nose/proxy.py", line 131, in addError
    formatted = plugins.formatError(self.test, err)
  File "/usr/local/lib/python3.1/dist-packages/nose-1.1.2-py3.1.egg/nose/plugins/manager.py", line 94, in __call__
    return self.call(*arg, **kw)
  File "/usr/local/lib/python3.1/dist-packages/nose-1.1.2-py3.1.egg/nose/plugins/manager.py", line 136, in chain
    result = meth(*arg, **kw)
  File "/usr/local/lib/python3.1/dist-packages/nose-1.1.2-py3.1.egg/nose/plugins/capture.py", line 81, in formatError
    return (ec, self.addCaptureToErr(ev, output), tb)
  File "/usr/local/lib/python3.1/dist-packages/nose-1.1.2-py3.1.egg/nose/plugins/capture.py", line 104, in addCaptureToErr
    msg = msg.decode('utf8', 'replace')
AttributeError: 'int' object has no attribute 'decode'

I am using nosetest 1.1.2 installed with easy_install3 under python3.1 on 
debian squeeze.

I believe there is a problem with conversion to python3 when installing the 
package, I search for differences between installed version and versioned 
source code on addCaptureToErr function I notice the following changes :

if hasattr(ev, '__unicode__'):
    #2.6+
    ev = unicode(ev)

becomes

if hasattr(ev, '__unicode__'):
    #2.6+
    ev = str(ev)

I guess 2to3 is replacing unicode function with str, but cannot detect the test 
string.

Original issue reported on code.google.com by jean.giard@gmail.com on 2 Aug 2011 at 7:44

GoogleCodeExporter commented 8 years ago
Nah, just looks like clumsy coding.  What's weird about this is the error 
message seems to be an int.  Could you post a simplified test suite that 
reproduces this error?  That way we can add a regression test.

Revision 16b847637ffaaca8d76404a59a487f8539e206d8 should fix it.  Please try

pip install -U hg+http://code.google.com/p/python-nose/#egg=nose

and let me know

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

GoogleCodeExporter commented 8 years ago
I managed to reproduce the problem with attached test.

I confirm it to be fixed when using latest revision as provided above.
Thanks.

Original comment by jean.giard@gmail.com on 3 Aug 2011 at 8:11

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by kumar.mcmillan on 21 Sep 2011 at 4:45