nose-devs/nose — Issue #438: Capture plugin with python 3
Author: jpellerin
Created: 2011-12-14 16:11:39+00:00
State: open

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.

Google Code Info:
Issue #: 442
Author: jean.giard@gmail.com
Created On: 2011-08-02T07:44:37.000Z
Closed On: