Workaround for cmdexec bug on Windows

This bug fails the entire pytest suite when executed with the
--lsof option in Python 2 on Windows.
This commit is contained in:
Bruno Oliveira 2015-07-24 19:21:57 -03:00
parent 9f94e443ff
commit 033def0a7a
2 changed files with 5 additions and 2 deletions

View File

@ -74,7 +74,10 @@ class LsofFdLeakChecker(object):
def matching_platform(self): def matching_platform(self):
try: try:
py.process.cmdexec("lsof -v") py.process.cmdexec("lsof -v")
except py.process.cmdexec.Error: except (py.process.cmdexec.Error, UnicodeDecodeError):
# cmdexec may raise UnicodeDecodeError on Windows systems
# with locale other than english:
# https://bitbucket.org/pytest-dev/py/issues/66
return False return False
else: else:
return True return True

View File

@ -650,7 +650,7 @@ def lsof_check():
try: try:
out = py.process.cmdexec("lsof -p %d" % pid) out = py.process.cmdexec("lsof -p %d" % pid)
except (py.process.cmdexec.Error, UnicodeDecodeError): except (py.process.cmdexec.Error, UnicodeDecodeError):
# about UnicodeDecodeError, see note on conftest.py # about UnicodeDecodeError, see note on pytester
pytest.skip("could not run 'lsof'") pytest.skip("could not run 'lsof'")
yield yield
out2 = py.process.cmdexec("lsof -p %d" % pid) out2 = py.process.cmdexec("lsof -p %d" % pid)