This commit is contained in:
holger krekel 2011-08-19 18:07:39 +02:00
commit 41b8a03b05
1 changed files with 8 additions and 4 deletions

View File

@ -15,6 +15,12 @@ import py
from _pytest.assertion import util from _pytest.assertion import util
# Windows gives ENOENT in places *nix gives ENOTDIR.
if sys.platform.startswith("win"):
PATH_COMPONENT_NOT_DIR = errno.ENOENT
else:
PATH_COMPONENT_NOT_DIR = errno.ENOTDIR
# py.test caches rewritten pycs in __pycache__. # py.test caches rewritten pycs in __pycache__.
if hasattr(imp, "get_tag"): if hasattr(imp, "get_tag"):
PYTEST_TAG = imp.get_tag() + "-PYTEST" PYTEST_TAG = imp.get_tag() + "-PYTEST"
@ -106,8 +112,7 @@ class AssertionRewritingHook(object):
# common case) or it's blocked by a non-dir node. In the # common case) or it's blocked by a non-dir node. In the
# latter case, we'll ignore it in _write_pyc. # latter case, we'll ignore it in _write_pyc.
pass pass
elif (e == errno.ENOTDIR or elif e == PATH_COMPONENT_NOT_DIR:
sys.platform == "win32" and e == errno.ENOENT):
# One of the path components was not a directory, likely # One of the path components was not a directory, likely
# because we're in a zip file. # because we're in a zip file.
write = False write = False
@ -160,8 +165,7 @@ def _write_pyc(co, source_path, pyc):
fp = open(pyc, "wb") fp = open(pyc, "wb")
except IOError: except IOError:
err = sys.exc_info()[1].errno err = sys.exc_info()[1].errno
if (err == errno.ENOTDIR or if err == PATH_COMPONENT_NOT_DIR:
sys.platform == "win32" and err == errno.ENOENT):
# This happens when we get a EEXIST in find_module creating the # This happens when we get a EEXIST in find_module creating the
# __pycache__ directory and __pycache__ is by some non-dir node. # __pycache__ directory and __pycache__ is by some non-dir node.
return False return False