* various jython related fixes.
* more care for print-errors including unicode-encoding related errors. --HG-- branch : trunk
This commit is contained in:
@@ -193,7 +193,7 @@ def test_builtin_patch_unpatch(monkeypatch):
|
||||
assert cpy_builtin.compile == mycompile
|
||||
|
||||
|
||||
def test_unicode_handling(testdir):
|
||||
def test_unicode_handling():
|
||||
value = py.builtin._totext('\xc4\x85\xc4\x87\n', 'utf-8').encode('utf8')
|
||||
def f():
|
||||
raise Exception(value)
|
||||
@@ -201,3 +201,19 @@ def test_unicode_handling(testdir):
|
||||
s = str(excinfo)
|
||||
if sys.version_info[0] < 3:
|
||||
u = unicode(excinfo)
|
||||
|
||||
def test_unicode_or_repr():
|
||||
from py._code.code import unicode_or_repr
|
||||
assert unicode_or_repr('hello') == "hello"
|
||||
if sys.version_info[0] < 3:
|
||||
s = unicode_or_repr('\xf6\xc4\x85')
|
||||
else:
|
||||
s = eval("unicode_or_repr(b'\\f6\\xc4\\x85')")
|
||||
assert 'print-error' in s
|
||||
assert 'c4' in s
|
||||
class A:
|
||||
def __repr__(self):
|
||||
raise ValueError()
|
||||
s = unicode_or_repr(A())
|
||||
assert 'print-error' in s
|
||||
assert 'ValueError' in s
|
||||
|
||||
@@ -129,8 +129,8 @@ class TestTerminalWriter:
|
||||
tw.write("x\n", red=True)
|
||||
l = tw.getlines()
|
||||
if sys.platform != "win32":
|
||||
assert len(l[0]) > 2, l
|
||||
assert len(l[1]) > 2, l
|
||||
assert len(l[0]) >= 2, l
|
||||
assert len(l[1]) >= 2, l
|
||||
|
||||
def test_attr_fullwidth(self, tw):
|
||||
tw.sep("-", "hello", fullwidth=70)
|
||||
|
||||
@@ -393,7 +393,8 @@ def test_setup_failure_does_not_kill_capturing(testdir):
|
||||
def test_fdfuncarg_skips_on_no_osdup(testdir):
|
||||
testdir.makepyfile("""
|
||||
import os
|
||||
del os.dup
|
||||
if hasattr(os, 'dup'):
|
||||
del os.dup
|
||||
def test_hello(capfd):
|
||||
pass
|
||||
""")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
from xml.dom import minidom
|
||||
import py
|
||||
import py, sys
|
||||
|
||||
def runandparse(testdir, *args):
|
||||
resultpath = testdir.tmpdir.join("junit.xml")
|
||||
@@ -104,7 +104,7 @@ class TestPython:
|
||||
name="test_collect_error")
|
||||
fnode = tnode.getElementsByTagName("failure")[0]
|
||||
assert_attr(fnode, message="collection failure")
|
||||
assert "invalid syntax" in fnode.toxml()
|
||||
assert "SyntaxError" in fnode.toxml()
|
||||
|
||||
def test_collect_skipped(self, testdir):
|
||||
testdir.makepyfile("import py ; py.test.skip('xyz')")
|
||||
@@ -130,7 +130,8 @@ class TestPython:
|
||||
assert result.ret == 1
|
||||
tnode = dom.getElementsByTagName("testcase")[0]
|
||||
fnode = tnode.getElementsByTagName("failure")[0]
|
||||
assert "hx" in fnode.toxml()
|
||||
if not sys.platform.startswith("java"):
|
||||
assert "hx" in fnode.toxml()
|
||||
|
||||
class TestNonPython:
|
||||
def test_summing_simple(self, testdir):
|
||||
|
||||
@@ -142,7 +142,7 @@ class TestWithFunctionIntegration:
|
||||
entry_lines = entry.splitlines()
|
||||
|
||||
assert entry_lines[0].startswith('! ')
|
||||
assert os.path.basename(__file__)[:-1] in entry_lines[0] #.py/.pyc
|
||||
assert os.path.basename(__file__)[:-9] in entry_lines[0] #.pyc/class
|
||||
assert entry_lines[-1][0] == ' '
|
||||
assert 'ValueError' in entry
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ class TestTerminal:
|
||||
excinfo = py.test.raises(ValueError, "raise ValueError('hello')")
|
||||
rep.pytest_internalerror(excinfo.getrepr())
|
||||
linecomp.assert_contains_lines([
|
||||
"INTERNALERROR> *raise ValueError*"
|
||||
"INTERNALERROR> *ValueError*hello*"
|
||||
])
|
||||
|
||||
def test_writeline(self, testdir, linecomp):
|
||||
|
||||
Reference in New Issue
Block a user