Skip to content

Commit 033def0

Browse files
committed
Workaround for cmdexec bug on Windows
This bug fails the entire pytest suite when executed with the --lsof option in Python 2 on Windows.
1 parent 9f94e44 commit 033def0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

_pytest/pytester.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ def isopen(line):
7474
def matching_platform(self):
7575
try:
7676
py.process.cmdexec("lsof -v")
77-
except py.process.cmdexec.Error:
77+
except (py.process.cmdexec.Error, UnicodeDecodeError):
78+
# cmdexec may raise UnicodeDecodeError on Windows systems
79+
# with locale other than english:
80+
# https://bitbucket.org/pytest-dev/py/issues/66
7881
return False
7982
else:
8083
return True

testing/test_capture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ def lsof_check():
650650
try:
651651
out = py.process.cmdexec("lsof -p %d" % pid)
652652
except (py.process.cmdexec.Error, UnicodeDecodeError):
653-
# about UnicodeDecodeError, see note on conftest.py
653+
# about UnicodeDecodeError, see note on pytester
654654
pytest.skip("could not run 'lsof'")
655655
yield
656656
out2 = py.process.cmdexec("lsof -p %d" % pid)

0 commit comments

Comments
 (0)