Skip to content

Commit 2185a92

Browse files
Close the base_url construction-guard test clients
Make the two CohereRerankProvider base_url construction-guard tests async and await provider.aclose() after each successful construction, so the underlying httpx.AsyncClient is not left open (a ResourceWarning under strict runs). The /v2-suffix rejection raises before a client is created, so only the accepted constructions need closing.
1 parent 8160bc9 commit 2185a92

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

tests/unit/test_retrieval_provider.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -792,18 +792,24 @@ def handler(_req: httpx.Request) -> httpx.Response: # pragma: no cover - never
792792
# --- construction guards + readiness ----------------------------------------
793793

794794

795-
def test_rerank_base_url_rejects_v2_suffix() -> None:
795+
async def test_rerank_base_url_rejects_v2_suffix() -> None:
796796
with pytest.raises(ValueError, match="host root"):
797797
CohereRerankProvider(base_url="https://api.cohere.com/v2", model="m")
798-
# The host root is accepted (no doubled /v2/v2).
799-
CohereRerankProvider(base_url="https://api.cohere.com", model="m")
798+
# The host root is accepted (no doubled /v2/v2). The /v2-suffix rejection
799+
# above raises in normalize_base_url before a client is created, so only the
800+
# accepted construction here needs closing.
801+
provider = CohereRerankProvider(base_url="https://api.cohere.com", model="m")
802+
await provider.aclose()
800803

801804

802-
def test_rerank_base_url_defaults_to_cohere_origin() -> None:
805+
async def test_rerank_base_url_defaults_to_cohere_origin() -> None:
803806
# base_url is optional per §8.4: an unspecified base_url binds the Cohere
804807
# origin (host root; the provider appends /v2/rerank itself).
805808
provider = CohereRerankProvider(model="rerank-test")
806-
assert provider.base_url == "https://api.cohere.com"
809+
try:
810+
assert provider.base_url == "https://api.cohere.com"
811+
finally:
812+
await provider.aclose()
807813

808814

809815
async def test_rerank_ready_probe_surfaces_invalid_model_on_404() -> None:

0 commit comments

Comments
 (0)