diff --git a/py/_path/local.py b/py/_path/local.py index 282a1bc6c..3ddfc80fd 100644 --- a/py/_path/local.py +++ b/py/_path/local.py @@ -5,7 +5,7 @@ import sys, os, stat, re, atexit import py from py._path import common -iswin32 = sys.platform == "win32" or (os._name == 'nt') +iswin32 = sys.platform == "win32" or (getattr(os, '_name', False) == 'nt') class Stat(object): def __getattr__(self, name): diff --git a/testing/path/test_local.py b/testing/path/test_local.py index 097e8195f..50f212bc2 100644 --- a/testing/path/test_local.py +++ b/testing/path/test_local.py @@ -4,6 +4,11 @@ from py.path import local from testing.path import common failsonjython = py.test.mark.xfail("sys.platform.startswith('java')") +win32only = py.test.mark.skipif( + "not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')") +failsonwin32 = py.test.mark.skipif( + "sys.platform == 'win32' or getattr(os, '_name', None) == 'nt'") + def pytest_funcarg__path1(request): def setup(): @@ -193,7 +198,7 @@ class TestLocalPath(common.CommonFSTests): assert l[2] == p3 class TestExecutionOnWindows: - pytestmark = py.test.mark.skipif("not (sys.platform == 'win32' or os._name == 'nt')") + pytestmark = win32only def test_sysfind(self): x = py.path.local.sysfind('cmd') @@ -201,7 +206,7 @@ class TestExecutionOnWindows: assert py.path.local.sysfind('jaksdkasldqwe') is None class TestExecution: - pytestmark = py.test.mark.skipif("sys.platform == 'win32' or os._name == 'nt'") + pytestmark = failsonwin32 def test_sysfind(self): x = py.path.local.sysfind('test') @@ -357,7 +362,7 @@ def test_samefile(tmpdir): assert p.samefile(p) class TestWINLocalPath: - pytestmark = py.test.mark.skipif("sys.platform != 'win32' and os._name != 'win32'") + pytestmark = win32only def test_owner_group_not_implemented(self, path1): py.test.raises(NotImplementedError, "path1.stat().owner") @@ -406,7 +411,7 @@ class TestWINLocalPath: old.chdir() class TestPOSIXLocalPath: - pytestmark = py.test.mark.skipif("sys.platform == 'win32' or os._name == 'nt'") + pytestmark = failsonwin32 def test_hardlink(self, tmpdir): linkpath = tmpdir.join('test')