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])
|
self.msg = py.builtin._totext(args[0])
|
||||||
except Exception:
|
except Exception:
|
||||||
self.msg = py.builtin._totext(
|
self.msg = py.builtin._totext(
|
||||||
"<[broken __repr__] %s at %0xd> %s"
|
"<[broken __repr__] %s at %0xd>"
|
||||||
% (args[0].__class__, id(args[0])))
|
% (args[0].__class__, id(args[0])))
|
||||||
else:
|
else:
|
||||||
f = py.code.Frame(sys._getframe(1))
|
f = py.code.Frame(sys._getframe(1))
|
||||||
|
|
|
@ -127,7 +127,7 @@ except NameError:
|
||||||
def assertrepr_compare(config, op, left, right):
|
def assertrepr_compare(config, op, left, right):
|
||||||
"""Return specialised explanations for some operators/operands"""
|
"""Return specialised explanations for some operators/operands"""
|
||||||
width = 80 - 15 - len(op) - 2 # 15 chars indentation, 1 space around op
|
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))
|
right_repr = py.io.saferepr(right, maxsize=width-len(left_repr))
|
||||||
summary = u('%s %s %s') % (left_repr, op, right_repr)
|
summary = u('%s %s %s') % (left_repr, op, right_repr)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import py, pytest
|
import py, pytest
|
||||||
|
@ -176,6 +177,15 @@ class TestAssert_reprcompare:
|
||||||
expl = ' '.join(callequal('foo', 'bar'))
|
expl = ' '.join(callequal('foo', 'bar'))
|
||||||
assert 'raised in repr()' not in expl
|
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):
|
def test_python25_compile_issue257(testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
def test_rewritten():
|
def test_rewritten():
|
||||||
|
|
Loading…
Reference in New Issue