Skip to content

Commit eef02fd

Browse files
committed
Unskip / get the end-to-end tests working for Windows.
1 parent 7a9e1f3 commit eef02fd

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

src/pip/_internal/utils/logging.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,30 @@ class BrokenStdoutLoggingError(Exception):
3737
pass
3838

3939

40-
if PY2:
41-
# BrokenPipeError does not exist in Python 2.
40+
# BrokenPipeError does not exist in Python 2 and, in addition, manifests
41+
# differently in Windows and non-Windows.
42+
if WINDOWS:
43+
# In Windows, a broken pipe can show up as EINVAL rather than EPIPE:
44+
# https://bugs.python.org/issue19612
45+
# https://bugs.python.org/issue30418
46+
if PY2:
47+
def _is_broken_pipe_error(exc_class, exc):
48+
"""See the docstring for non-Windows Python 3 below."""
49+
return (exc_class is IOError and
50+
exc.errno in (errno.EINVAL, errno.EPIPE))
51+
else:
52+
# In Windows, a broken pipe IOError became OSError in Python 3.
53+
def _is_broken_pipe_error(exc_class, exc):
54+
"""See the docstring for non-Windows Python 3 below."""
55+
return ((exc_class is BrokenPipeError) or # noqa: F821
56+
(exc_class is OSError and
57+
exc.errno in (errno.EINVAL, errno.EPIPE)))
58+
elif PY2:
59+
def _is_broken_pipe_error(exc_class, exc):
60+
"""See the docstring for non-Windows Python 3 below."""
61+
return (exc_class is IOError and exc.errno == errno.EPIPE)
62+
else:
63+
# Then we are in the non-Windows Python 3 case.
4264
def _is_broken_pipe_error(exc_class, exc):
4365
"""
4466
Return whether an exception is a broken pipe error.
@@ -47,10 +69,6 @@ def _is_broken_pipe_error(exc_class, exc):
4769
exc_class: an exception class.
4870
exc: an exception instance.
4971
"""
50-
return (exc_class is IOError and exc.errno == errno.EPIPE)
51-
52-
else:
53-
def _is_broken_pipe_error(exc_class, exc):
5472
return (exc_class is BrokenPipeError) # noqa: F821
5573

5674

tests/functional/test_broken_stdout.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import subprocess
22
import sys
33

4-
import pytest
5-
6-
from pip._internal.utils.compat import WINDOWS
7-
84
if sys.version_info < (3, 6):
95
_BROKEN_STDOUT_RETURN_CODE = 1
106
else:
@@ -19,7 +15,6 @@ def setup_broken_stdout_test(args, deprecated_python):
1915
)
2016
# Call close() on stdout to cause a broken pipe.
2117
proc.stdout.close()
22-
# This line causes a timeout on Windows.
2318
returncode = proc.wait()
2419
stderr = proc.stderr.read().decode('utf-8')
2520

@@ -32,7 +27,6 @@ def setup_broken_stdout_test(args, deprecated_python):
3227
return stderr, returncode
3328

3429

35-
@pytest.mark.skipif(WINDOWS, reason="test times out on Windows")
3630
def test_broken_stdout_pipe(deprecated_python):
3731
"""
3832
Test a broken pipe to stdout.
@@ -48,7 +42,6 @@ def test_broken_stdout_pipe(deprecated_python):
4842
assert returncode == _BROKEN_STDOUT_RETURN_CODE
4943

5044

51-
@pytest.mark.skipif(WINDOWS, reason="test times out on Windows")
5245
def test_broken_stdout_pipe__verbose(deprecated_python):
5346
"""
5447
Test a broken pipe to stdout with verbose logging enabled.

0 commit comments

Comments
 (0)