a couple of more fixes/refinements for getting py.test to run better on jython/win32

--HG--
branch : trunk
This commit is contained in:
holger krekel 2010-04-21 03:50:03 -07:00
parent 5715bbd6f5
commit fe34a8a15a
6 changed files with 25 additions and 9 deletions

View File

@ -13,6 +13,7 @@ syntax:glob
*.html
*.class
*.orig
*~
build/
dist/

View File

@ -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):]

View File

@ -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:

View File

@ -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')