Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ classifiers = [
"Environment :: Console",
]
dependencies = [
"httpx>=0.27,<1.0",
"httpx2>=2.4,<3.0",
"pydantic>=2.0,<3.0",
]

Expand Down
2 changes: 1 addition & 1 deletion src/hyperping/_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from typing import Any
from urllib.parse import urlsplit

import httpx
import httpx2 as httpx
from pydantic import SecretStr

from hyperping._async_healthchecks_mixin import AsyncHealthchecksMixin
Expand Down
2 changes: 1 addition & 1 deletion src/hyperping/_async_mcp_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import time
from typing import Any

import httpx
import httpx2 as httpx
from pydantic import SecretStr

from hyperping._internals import validate_base_url
Expand Down
2 changes: 1 addition & 1 deletion src/hyperping/_mcp_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import time
from typing import Any

import httpx
import httpx2 as httpx
from pydantic import SecretStr

from hyperping._internals import validate_base_url
Expand Down
2 changes: 1 addition & 1 deletion src/hyperping/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from typing import Any
from urllib.parse import urlsplit

import httpx
import httpx2 as httpx
from pydantic import SecretStr

from hyperping._circuit_breaker import (
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@
from collections.abc import Generator

import pytest
from respx.mocks import HTTPCoreMocker

from hyperping.client import HyperpingClient, RetryConfig
from hyperping.endpoints import API_BASE

# httpx2 uses httpcore2 instead of httpcore; extend respx's default mocker so
# that @respx.mock intercepts requests made through httpx2 clients.
HTTPCoreMocker.add_targets(
"httpcore2._sync.connection.HTTPConnection",
"httpcore2._sync.connection_pool.ConnectionPool",
"httpcore2._sync.http_proxy.HTTPProxy",
"httpcore2._async.connection.AsyncHTTPConnection",
"httpcore2._async.connection_pool.AsyncConnectionPool",
"httpcore2._async.http_proxy.AsyncHTTPProxy",
)


@pytest.fixture
def client() -> Generator[HyperpingClient, None, None]:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from unittest.mock import AsyncMock, MagicMock, patch

import httpx
import httpx2 as httpx
import pytest
import pytest_asyncio

Expand Down
9 changes: 5 additions & 4 deletions tests/unit/test_client_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from unittest.mock import patch

import httpcore2
import httpx
import pytest
import respx
Expand Down Expand Up @@ -69,7 +70,7 @@ def test_ping_api_error_wraps(self) -> None:
def test_ping_timeout_wraps(self) -> None:
"""ping() wraps httpx.TimeoutException."""
respx.get(f"{API_BASE}{Endpoint.MONITORS}").mock(
side_effect=httpx.TimeoutException("timed out")
side_effect=httpcore2.ConnectTimeout("timed out")
)
c = HyperpingClient(
api_key="sk_test",
Expand All @@ -83,7 +84,7 @@ def test_ping_timeout_wraps(self) -> None:
def test_ping_request_error_wraps(self) -> None:
"""ping() wraps httpx.RequestError."""
respx.get(f"{API_BASE}{Endpoint.MONITORS}").mock(
side_effect=httpx.ConnectError("connection refused")
side_effect=httpcore2.ConnectError("connection refused")
)
c = HyperpingClient(
api_key="sk_test",
Expand Down Expand Up @@ -250,7 +251,7 @@ class TestTimeoutRetry:
def test_timeout_retries_then_raises(self) -> None:
"""Timeout after all retries raises HyperpingAPIError."""
respx.get(f"{API_BASE}{Endpoint.MONITORS}").mock(
side_effect=httpx.TimeoutException("timed out")
side_effect=httpcore2.ConnectTimeout("timed out")
)
with patch("hyperping.client.time.sleep"):
c = HyperpingClient(
Expand All @@ -265,7 +266,7 @@ def test_timeout_retries_then_raises(self) -> None:
def test_request_error_retries_then_raises(self) -> None:
"""Connection error after all retries raises HyperpingAPIError."""
respx.get(f"{API_BASE}{Endpoint.MONITORS}").mock(
side_effect=httpx.ConnectError("connection refused")
side_effect=httpcore2.ConnectError("connection refused")
)
with patch("hyperping.client.time.sleep"):
c = HyperpingClient(
Expand Down
48 changes: 43 additions & 5 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.