diff --git a/.hgignore b/.hgignore index af8d636b3..b0e965ec5 100644 --- a/.hgignore +++ b/.hgignore @@ -13,6 +13,7 @@ syntax:glob *.html *.class *.orig +*~ build/ dist/ diff --git a/py/_path/common.py b/py/_path/common.py index 9352a4a11..15aa80f3c 100644 --- a/py/_path/common.py +++ b/py/_path/common.py @@ -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):] diff --git a/py/_plugin/pytest_pytester.py b/py/_plugin/pytest_pytester.py index 1644a83d5..a87d4c574 100644 --- 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 diff --git a/py/_plugin/pytest_skipping.py b/py/_plugin/pytest_skipping.py index 25bf9d970..af2244862 100644 --- 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: diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index e9a7584aa..9e056bf59 100644 --- 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 diff --git a/testing/path/test_local.py b/testing/path/test_local.py index 50f212bc2..2eab94fca 100644 --- 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')