Issue #10 resolved

scripttest.backwardscompat.string fails in Python 2 when input is a unicode

Marc Abramowitz
created an issue

Using the test I added in https://bitbucket.org/ianb/scripttest/pull-request/1/fix-issue-9-add-test-for:

{{{

!python

$ python -V Python 2.7

$ nosetests -s -v tests/test_string.py tests.test_string.skip_test_if_not_python_2 ... ok tests.test_string.skip_test_if_not_python_3 ... SKIP tests.test_string.test_python_2_string_with_ascii_str ... ok tests.test_string.test_python_2_string_with_utf8_str ... ok tests.test_string.test_python_2_string_with_ascii_unicode ... ok tests.test_string.test_python_2_string_with_utf8_unicode ... ERROR tests.test_string.test_python_3_string_with_ascii_bytes ... SKIP tests.test_string.test_python_3_string_with_utf8_bytes ... SKIP tests.test_string.test_python_3_string_with_ascii_str ... SKIP tests.test_string.test_python_3_string_with_utf8_str ... SKIP

====================================================================== ERROR: tests.test_string.test_python_2_string_with_utf8_unicode


Traceback (most recent call last): File "/Users/marc/python/virtualenvs/pip-python2/lib/python2.7/site-packages/nose/case.py", line 197, in runTest self.test(*self.arg) File "/Users/marc/dev/hg-repos/scripttest/tests/test_string.py", line 79, in test_python_2_string_with_utf8_unicode result = string(utf8_unicode) File "/Users/marc/dev/hg-repos/scripttest/scripttest/backwardscompat.py", line 9, in string return string.decode('utf-8') File "/Users/marc/python/virtualenvs/pip-python2/lib/python2.7/encodings/utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 2: ordinal not in range(128)


Ran 10 tests in 0.178s

FAILED (SKIP=5, errors=1) }}}