first round of fixing jython compatibility issues, marking some tests as xfail-on-jython
--HG-- branch : trunk
This commit is contained in:
parent
33bd39053f
commit
d2e6cd0523
|
@ -37,7 +37,7 @@ def _format_explanation(explanation):
|
|||
return '\n'.join(result)
|
||||
|
||||
|
||||
if sys.version_info >= (2, 6):
|
||||
if sys.version_info >= (2, 6) or (sys.platform.startswith("java")):
|
||||
from _py.code._assertionnew import interpret
|
||||
else:
|
||||
from _py.code._assertionold import interpret
|
||||
|
|
|
@ -28,6 +28,9 @@ class Code(object):
|
|||
if rec-cursive is true then dive into code
|
||||
objects contained in co_consts.
|
||||
"""
|
||||
if sys.platform.startswith("java"):
|
||||
# XXX jython does not support the below co_filename hack
|
||||
return self.raw
|
||||
names = [x for x in dir(self.raw) if x[:3] == 'co_']
|
||||
for name in kwargs:
|
||||
if name not in names:
|
||||
|
|
|
@ -50,6 +50,8 @@ def warn(msg, stacklevel=1, function=None):
|
|||
fnl = filename.lower()
|
||||
if fnl.endswith(".pyc") or fnl.endswith(".pyo"):
|
||||
filename = filename[:-1]
|
||||
elif fnl.endswith("$py.class"):
|
||||
filename = filename.replace('$py.class', '.py')
|
||||
else:
|
||||
if module == "__main__":
|
||||
try:
|
||||
|
|
|
@ -8,6 +8,9 @@ def pytest_addoption(parser):
|
|||
help="disable python assert expression reinterpretation."),
|
||||
|
||||
def pytest_configure(config):
|
||||
if sys.platform.startswith("java"):
|
||||
return # XXX assertions don't work yet with jython 2.5.1
|
||||
|
||||
if not config.getvalue("noassert") and not config.getvalue("nomagic"):
|
||||
warn_about_missing_assertion()
|
||||
config._oldassertion = py.builtin.builtins.AssertionError
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import py
|
||||
|
||||
pytestmark = py.test.mark.skipif("sys.platform.startswith('java')")
|
||||
|
||||
def exvalue():
|
||||
return py.std.sys.exc_info()[1]
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ import py
|
|||
import sys
|
||||
from _py.code.code import safe_repr
|
||||
|
||||
failsonjython = py.test.mark.xfail("sys.platform.startswith('java')")
|
||||
|
||||
def test_newcode():
|
||||
source = "i = 3"
|
||||
co = compile(source, '', 'exec')
|
||||
|
@ -16,10 +18,12 @@ def test_ne():
|
|||
code2 = py.code.Code(compile('foo = "baz"', '', 'exec'))
|
||||
assert code2 != code1
|
||||
|
||||
@failsonjython
|
||||
def test_newcode_unknown_args():
|
||||
code = py.code.Code(compile("", '', 'exec'))
|
||||
py.test.raises(TypeError, 'code.new(filename="hello")')
|
||||
|
||||
@failsonjython
|
||||
def test_newcode_withfilename():
|
||||
source = py.code.Source("""
|
||||
def f():
|
||||
|
@ -44,6 +48,7 @@ def test_newcode_withfilename():
|
|||
assert 'f' in names
|
||||
assert 'g' in names
|
||||
|
||||
@failsonjython
|
||||
def test_newcode_with_filename():
|
||||
source = "i = 3"
|
||||
co = compile(source, '', 'exec')
|
||||
|
@ -58,6 +63,7 @@ def test_newcode_with_filename():
|
|||
assert str(s) == source
|
||||
|
||||
|
||||
@failsonjython
|
||||
def test_new_code_object_carries_filename_through():
|
||||
class mystr(str):
|
||||
pass
|
||||
|
|
|
@ -384,7 +384,7 @@ raise ValueError()
|
|||
|
||||
def test_repr_local(self):
|
||||
p = FormattedExcinfo(showlocals=True)
|
||||
loc = {'y': 5, 'z': 7, 'x': 3, '__builtins__': __builtins__}
|
||||
loc = {'y': 5, 'z': 7, 'x': 3, '__builtins__': {}} # __builtins__}
|
||||
reprlocals = p.repr_locals(loc)
|
||||
assert reprlocals.lines
|
||||
assert reprlocals.lines[0] == '__builtins__ = <builtins>'
|
||||
|
|
|
@ -132,6 +132,7 @@ class CommonFSTests(object):
|
|||
assert not l1.relto(l2)
|
||||
assert not l2.relto(l1)
|
||||
|
||||
@py.test.mark.xfail("sys.platform.startswith('java')")
|
||||
def test_listdir(self, path1):
|
||||
l = path1.listdir()
|
||||
assert path1.join('sampledir') in l
|
||||
|
@ -177,6 +178,7 @@ class CommonFSTests(object):
|
|||
assert "sampledir" in l
|
||||
assert "otherdir" in l
|
||||
|
||||
@py.test.mark.xfail("sys.platform.startswith('java')")
|
||||
def test_visit_ignore(self, path1):
|
||||
p = path1.join('nonexisting')
|
||||
assert list(p.visit(ignore=py.error.ENOENT)) == []
|
||||
|
|
|
@ -3,6 +3,8 @@ import sys
|
|||
from py.path import local
|
||||
from testing.path import common
|
||||
|
||||
failsonjython = py.test.mark.xfail("sys.platform.startswith('java')")
|
||||
|
||||
def pytest_funcarg__path1(request):
|
||||
def setup():
|
||||
path1 = request.config.mktemp("path1")
|
||||
|
@ -545,11 +547,13 @@ class TestPOSIXLocalPath:
|
|||
for x,y in oldmodes.items():
|
||||
x.chmod(y)
|
||||
|
||||
@failsonjython
|
||||
def test_chown_identity(self, path1):
|
||||
owner = path1.stat().owner
|
||||
group = path1.stat().group
|
||||
path1.chown(owner, group)
|
||||
|
||||
@failsonjython
|
||||
def test_chown_dangling_link(self, path1):
|
||||
owner = path1.stat().owner
|
||||
group = path1.stat().group
|
||||
|
@ -560,6 +564,7 @@ class TestPOSIXLocalPath:
|
|||
finally:
|
||||
x.remove(rec=0)
|
||||
|
||||
@failsonjython
|
||||
def test_chown_identity_rec_mayfail(self, path1):
|
||||
owner = path1.stat().owner
|
||||
group = path1.stat().group
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import py, os, sys
|
||||
from _py.test.plugin.pytest_capture import CaptureManager
|
||||
|
||||
needsosdup = py.test.mark.xfail("not hasattr(os, 'dup')")
|
||||
|
||||
class TestCaptureManager:
|
||||
def test_getmethod_default_no_fd(self, testdir, monkeypatch):
|
||||
config = testdir.parseconfig(testdir.tmpdir)
|
||||
assert config.getvalue("capture") is None
|
||||
capman = CaptureManager()
|
||||
monkeypatch.delattr(os, 'dup')
|
||||
monkeypatch.delattr(os, 'dup', raising=False)
|
||||
try:
|
||||
assert capman._getmethod(config, None) == "sys"
|
||||
finally:
|
||||
|
@ -16,14 +18,21 @@ class TestCaptureManager:
|
|||
config = testdir.parseconfig(testdir.tmpdir)
|
||||
assert config.getvalue("capture") is None
|
||||
capman = CaptureManager()
|
||||
assert capman._getmethod(config, None) == "fd" # default
|
||||
hasfd = hasattr(os, 'dup')
|
||||
if hasfd:
|
||||
assert capman._getmethod(config, None) == "fd"
|
||||
else:
|
||||
assert capman._getmethod(config, None) == "sys"
|
||||
|
||||
for name in ('no', 'fd', 'sys'):
|
||||
if not hasfd and name == 'fd':
|
||||
continue
|
||||
sub = testdir.tmpdir.mkdir("dir" + name)
|
||||
sub.ensure("__init__.py")
|
||||
sub.join("conftest.py").write('option_capture = %r' % name)
|
||||
assert capman._getmethod(config, sub.join("test_hello.py")) == name
|
||||
|
||||
@needsosdup
|
||||
@py.test.mark.multi(method=['no', 'fd', 'sys'])
|
||||
def test_capturing_basic_api(self, method):
|
||||
capouter = py.io.StdCaptureFD()
|
||||
|
@ -43,6 +52,7 @@ class TestCaptureManager:
|
|||
finally:
|
||||
capouter.reset()
|
||||
|
||||
@needsosdup
|
||||
def test_juggle_capturings(self, testdir):
|
||||
capouter = py.io.StdCaptureFD()
|
||||
try:
|
||||
|
@ -242,10 +252,13 @@ class TestLoggingInteraction:
|
|||
# here we check a fundamental feature
|
||||
rootdir = str(py.path.local(py.__file__).dirpath().dirpath())
|
||||
p = testdir.makepyfile("""
|
||||
import sys
|
||||
import sys, os
|
||||
sys.path.insert(0, %r)
|
||||
import py, logging
|
||||
cap = py.io.StdCaptureFD(out=False, in_=False)
|
||||
if hasattr(os, 'dup'):
|
||||
cap = py.io.StdCaptureFD(out=False, in_=False)
|
||||
else:
|
||||
cap = py.io.StdCapture(out=False, in_=False)
|
||||
logging.warn("hello1")
|
||||
outerr = cap.suspend()
|
||||
|
||||
|
@ -328,7 +341,8 @@ class TestCaptureFuncarg:
|
|||
assert out.startswith("42")
|
||||
""")
|
||||
reprec.assertoutcome(passed=1)
|
||||
|
||||
|
||||
@needsosdup
|
||||
def test_stdfd_functional(self, testdir):
|
||||
reprec = testdir.inline_runsource("""
|
||||
def test_hello(capfd):
|
||||
|
@ -351,6 +365,7 @@ class TestCaptureFuncarg:
|
|||
"*1 error*",
|
||||
])
|
||||
|
||||
@needsosdup
|
||||
def test_keyboardinterrupt_disables_capturing(self, testdir):
|
||||
p = testdir.makepyfile("""
|
||||
def test_hello(capfd):
|
||||
|
|
|
@ -189,7 +189,7 @@ class TestPrunetraceback:
|
|||
assert "__import__" not in result.stdout.str(), "too long traceback"
|
||||
result.stdout.fnmatch_lines([
|
||||
"*ERROR during collection*",
|
||||
">*import not_exists*"
|
||||
"*mport*not_exists*"
|
||||
])
|
||||
|
||||
class TestCustomConftests:
|
||||
|
|
Loading…
Reference in New Issue