Add test for unicode assertion descriptions
Also clean up a few debugging leftovers.
This commit is contained in:
parent
a5c075c4e2
commit
e3a945a0b5
|
@ -11,7 +11,7 @@ class AssertionError(BuiltinAssertionError):
|
|||
self.msg = py.builtin._totext(args[0])
|
||||
except Exception:
|
||||
self.msg = py.builtin._totext(
|
||||
"<[broken __repr__] %s at %0xd> %s"
|
||||
"<[broken __repr__] %s at %0xd>"
|
||||
% (args[0].__class__, id(args[0])))
|
||||
else:
|
||||
f = py.code.Frame(sys._getframe(1))
|
||||
|
|
|
@ -127,7 +127,7 @@ except NameError:
|
|||
def assertrepr_compare(config, op, left, right):
|
||||
"""Return specialised explanations for some operators/operands"""
|
||||
width = 80 - 15 - len(op) - 2 # 15 chars indentation, 1 space around op
|
||||
left_repr = py.io.saferepr(left, maxsize=int(width/2)) # XXX mangles unicode
|
||||
left_repr = py.io.saferepr(left, maxsize=int(width/2))
|
||||
right_repr = py.io.saferepr(right, maxsize=width-len(left_repr))
|
||||
summary = u('%s %s %s') % (left_repr, op, right_repr)
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
|
||||
import py, pytest
|
||||
|
@ -176,6 +177,15 @@ class TestAssert_reprcompare:
|
|||
expl = ' '.join(callequal('foo', 'bar'))
|
||||
assert 'raised in repr()' not in expl
|
||||
|
||||
def test_unicode(self):
|
||||
left = py.builtin._totext('£€', 'utf-8')
|
||||
right = py.builtin._totext('£', 'utf-8')
|
||||
expl = callequal(left, right)
|
||||
assert expl[0] == py.builtin._totext("'£€' == '£'", 'utf-8')
|
||||
assert expl[1] == py.builtin._totext('- £€', 'utf-8')
|
||||
assert expl[2] == py.builtin._totext('+ £', 'utf-8')
|
||||
|
||||
|
||||
def test_python25_compile_issue257(testdir):
|
||||
testdir.makepyfile("""
|
||||
def test_rewritten():
|
||||
|
|
Loading…
Reference in New Issue