pombreda / python-nose

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

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 15: ordinal not in range(128) #402

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I originally reported this issue with django-nose. They pointed me over here:

https://github.com/jbalogh/django-nose/issues/31

If I write a test like this:

self.assertContains(response, u'名')
I get a stacktrace like this:

Traceback (most recent call last):
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/case.py", line 133, in run
    self.runTest(result)
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/case.py", line 151, in runTest
    test(result)
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/django/test/testcases.py", line 264, in __call__
    super(TransactionTestCase, self).__call__(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/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/proxy.py", line 136, in addFailure
    formatted = plugins.formatFailure(self.test, err)
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/plugins/manager.py", line 94, in __call__
    return self.call(*arg, **kw)
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/plugins/manager.py", line 136, in chain
    result = meth(*arg, **kw)
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/plugins/capture.py", line 86, in formatFailure
    return self.formatError(test, err)
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/plugins/capture.py", line 81, in formatError
    return (ec, self.addCaptureToErr(ev, output), tb)
  File "/Users/poswald/.virtualenvs/hats/lib/python2.6/site-packages/nose/plugins/capture.py", line 90, in addCaptureToErr
    output, ln('>> end captured stdout <<')])
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 15: 
ordinal not in range(128)

It is not able to print the unicode character. Running it in the django test 
runner we get the output correctly:

AssertionError: Couldn't find '名' in response
Here's my setup:

 $ pip freeze | grep nose
django-nose==0.1.2
nose==1.0.0

This is on a failing test so it is trying to print out the result. Note that 
this seems similar to this closed issue:

http://code.google.com/p/python-nose/issues/detail?id=227

Original issue reported on code.google.com by paulosw...@gmail.com on 2 Mar 2011 at 3:24

GoogleCodeExporter commented 9 years ago
I also has similar exception:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 15: 
ordinal not in range(128)

I also tried to run similar script w/o NOSE, then it's OK.
So I assume it's a NOSE issue.

Thanks.

Original comment by jacksonchenjp on 21 Mar 2011 at 5:54

GoogleCodeExporter commented 9 years ago
BTW:
I tried both nose-0.11.0 and nose-0.11.3 .
Python is v2.7

Original comment by jacksonchenjp on 21 Mar 2011 at 5:55

GoogleCodeExporter commented 9 years ago
Thanks.  This is fixed in r 2b384e24638c and will be released in 1.0.1

Original comment by kumar.mcmillan on 21 Mar 2011 at 3:58