a couple of more fixes/refinements for getting py.test to run better on jython/win32
--HG-- branch : trunk
This commit is contained in:
parent
5715bbd6f5
commit
fe34a8a15a
|
@ -184,7 +184,7 @@ newline will be removed from the end of each line. """
|
|||
#assert strrelpath[-1] == self.sep
|
||||
#assert strrelpath[-2] != self.sep
|
||||
strself = str(self)
|
||||
if sys.platform == "win32":
|
||||
if sys.platform == "win32" or getattr(os, '_name', None) == 'nt':
|
||||
if os.path.normcase(strself).startswith(
|
||||
os.path.normcase(strrelpath)):
|
||||
return strself[len(strrelpath):]
|
||||
|
|
|
@ -315,8 +315,8 @@ class TmpTestdir:
|
|||
else:
|
||||
cmdlinename = scriptname.replace(".", "")
|
||||
assert hasattr(py.cmdline, cmdlinename), cmdlinename
|
||||
source = ("import sys ; sys.path.insert(0, %r); "
|
||||
"import py ; py.cmdline.%s()" %
|
||||
source = ("import sys;sys.path.insert(0,%r);"
|
||||
"import py;py.cmdline.%s()" %
|
||||
(str(py._pydir.dirpath()), cmdlinename))
|
||||
return (sys.executable, "-c", source,)
|
||||
|
||||
|
@ -328,7 +328,7 @@ class TmpTestdir:
|
|||
|
||||
def _getsysprepend(self):
|
||||
if not self.request.config.getvalue("toolsonpath"):
|
||||
s = "import sys ; sys.path.insert(0, %r) ; " % str(py._pydir.dirpath())
|
||||
s = "import sys;sys.path.insert(0,%r);" % str(py._pydir.dirpath())
|
||||
else:
|
||||
s = ""
|
||||
return s
|
||||
|
|
|
@ -196,7 +196,7 @@ def evalexpression(item, keyword):
|
|||
expr, result = None, True
|
||||
for expr in markholder.args:
|
||||
if isinstance(expr, str):
|
||||
result = eval(expr, d)
|
||||
result = cached_eval(item.config, expr, d)
|
||||
else:
|
||||
result = expr
|
||||
if not result:
|
||||
|
@ -204,6 +204,18 @@ def evalexpression(item, keyword):
|
|||
return expr, result
|
||||
return None, False
|
||||
|
||||
def cached_eval(config, expr, d):
|
||||
if not hasattr(config, '_evalcache'):
|
||||
config._evalcache = {}
|
||||
try:
|
||||
return config._evalcache[expr]
|
||||
except KeyError:
|
||||
#import sys
|
||||
#print >>sys.stderr, ("cache-miss: %r" % expr)
|
||||
config._evalcache[expr] = x = eval(expr, d)
|
||||
return x
|
||||
|
||||
|
||||
def folded_skips(skipped):
|
||||
d = {}
|
||||
for event in skipped:
|
||||
|
|
|
@ -85,7 +85,7 @@ class TestGeneralUsage:
|
|||
assert result.ret == 0
|
||||
|
||||
def test_pydoc(self, testdir):
|
||||
result = testdir.runpython_c("import py ; help(py.test)")
|
||||
result = testdir.runpython_c("import py;help(py.test)")
|
||||
assert result.ret == 0
|
||||
s = result.stdout.str()
|
||||
assert 'MarkGenerator' in s
|
||||
|
|
|
@ -4,9 +4,11 @@ from py.path import local
|
|||
from testing.path import common
|
||||
|
||||
failsonjython = py.test.mark.xfail("sys.platform.startswith('java')")
|
||||
failsonjywin32 = py.test.mark.xfail("sys.platform.startswith('java') "
|
||||
"and getattr(os, '_name', None) == 'nt'")
|
||||
win32only = py.test.mark.skipif(
|
||||
"not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')")
|
||||
failsonwin32 = py.test.mark.skipif(
|
||||
skiponwin32 = py.test.mark.skipif(
|
||||
"sys.platform == 'win32' or getattr(os, '_name', None) == 'nt'")
|
||||
|
||||
|
||||
|
@ -90,6 +92,7 @@ class TestLocalPath(common.CommonFSTests):
|
|||
finally:
|
||||
f.close()
|
||||
|
||||
@failsonjywin32
|
||||
def test_setmtime(self):
|
||||
import tempfile
|
||||
import time
|
||||
|
@ -206,7 +209,7 @@ class TestExecutionOnWindows:
|
|||
assert py.path.local.sysfind('jaksdkasldqwe') is None
|
||||
|
||||
class TestExecution:
|
||||
pytestmark = failsonwin32
|
||||
pytestmark = skiponwin32
|
||||
|
||||
def test_sysfind(self):
|
||||
x = py.path.local.sysfind('test')
|
||||
|
@ -411,7 +414,7 @@ class TestWINLocalPath:
|
|||
old.chdir()
|
||||
|
||||
class TestPOSIXLocalPath:
|
||||
pytestmark = failsonwin32
|
||||
pytestmark = skiponwin32
|
||||
|
||||
def test_hardlink(self, tmpdir):
|
||||
linkpath = tmpdir.join('test')
|
||||
|
|
Loading…
Reference in New Issue