[py-svn] py-trunk commit 95af339213dc: a couple of more fixes/refinements for getting py.test to run better on jython/win32
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Apr 21 12:50:32 CEST 2010
# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview
# User holger krekel <holger at merlinux.eu>
# Date 1271847003 25200
# Node ID 95af339213dc1c085fba4c2ef246107162aa46c9
# Parent 0e098b4734bc30dc29d6e9a2a03b653399ddb041
a couple of more fixes/refinements for getting py.test to run better on jython/win32
--- a/testing/acceptance_test.py
+++ b/testing/acceptance_test.py
@@ -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
--- a/py/_path/common.py
+++ b/py/_path/common.py
@@ -184,7 +184,7 @@ newline will be removed from the end of
#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):]
--- a/py/_plugin/pytest_skipping.py
+++ b/py/_plugin/pytest_skipping.py
@@ -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:
--- a/testing/path/test_local.py
+++ b/testing/path/test_local.py
@@ -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')
--- a/py/_plugin/pytest_pytester.py
+++ b/py/_plugin/pytest_pytester.py
@@ -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
--- a/.hgignore
+++ b/.hgignore
@@ -13,6 +13,7 @@ syntax:glob
*.html
*.class
*.orig
+*~
build/
dist/
More information about the pytest-commit
mailing list