Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,30 @@ class ExampleNetworkError(UserWarning):
_NETWORK_ERROR_PATTERNS = (
"urllib.error.HTTPError",
"urllib.error.URLError",
"http.client.RemoteDisconnected",
"http.client.IncompleteRead",
"http.client.BadStatusLine",
"ConnectionError",
"ConnectionAbortedError",
"ConnectionRefusedError",
"ConnectionResetError",
"RemoteDisconnected",
"TimeoutError",
"requests.exceptions.ConnectionError",
"requests.exceptions.Timeout",
"socket.gaierror",
"socket.timeout",
"ssl.SSLError",
)


def _network_error_pattern(output):
for pattern in _NETWORK_ERROR_PATTERNS:
if pattern in output:
return pattern
return None


class _FakeModule:
"""Minimal module-like object so the cuml.accel xfail plugin can read
``item.module.__name__`` without crashing on custom test items."""
Expand Down Expand Up @@ -97,14 +113,14 @@ def runtest(self):
pytest.xfail(reason=f"Timeout: example exceeded {timeout}s")
if result.returncode != 0:
stderr = result.stderr
for pattern in _NETWORK_ERROR_PATTERNS:
if pattern in stderr:
warnings.warn(
f"Example {self.path.name} failed due to network error"
f" ({pattern})",
ExampleNetworkError,
)
pytest.xfail(reason=f"Network error: {pattern}")
pattern = _network_error_pattern(result.stderr + result.stdout)
if pattern:
warnings.warn(
f"Example {self.path.name} failed due to network error"
f" ({pattern})",
ExampleNetworkError,
)
pytest.xfail(reason=f"Network error: {pattern}")
if len(stderr) > 4000:
stderr = "...\n" + stderr[-4000:]
raise ExampleFailed(stderr)
Comment thread
csadorf marked this conversation as resolved.
Expand Down
Loading