Ezio Melotti <ezio.melo...@gmail.com> added the comment:

If you really want the diff you could use assertMultiLineEqual, but even on 
Python 2 you shouldn't mix str and unicode.  I would rather fix the code to 
return unicode than using assertMultilineEqual to get a diff between str and 
unicode.  Moreover assertMultiLineEqual only works if the str happens to be 
ASCII-only:

>>> class MyTest(TestCase):
...   def test_foo(self):
...     self.assertMultiLineEqual('bàr', u'bàz')
... 
>>> unittest.main(exit=False)
E
======================================================================
ERROR: test_foo (__main__.MyTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "<stdin>", line 3, in test_foo
  File "/home/wolf/dev/py/2.7/Lib/unittest/case.py", line 920, in 
assertMultiLineEqual
    diff = '\n' + ''.join(difflib.ndiff(firstlines, secondlines))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal 
not in range(128)

----------------------------------------------------------------------

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to