Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

ci(tests): share the loopback allow list in the unit conftest

yunengdf7a3d2d1ea1
diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py
index 253ae7a6119..3bdab1d231a 100644
--- a/tests/unit/conftest.py
+++ b/tests/unit/conftest.py
@@ -1,16 +1,23 @@
from collections.abc import Iterator
+from typing import Final
import pytest
from pytest_socket import enable_socket, socket_allow_hosts
+LOOPBACK_HOSTS: Final = ["127.0.0.1", "::1"]
+
+
+def _allow_loopback_only() -> None:
+ socket_allow_hosts(LOOPBACK_HOSTS, allow_unix_socket=True)
+
@pytest.fixture(autouse=True, scope="session")
def block_external_sockets() -> Iterator[None]:
- socket_allow_hosts(["127.0.0.1", "::1"], allow_unix_socket=True)
+ _allow_loopback_only()
yield
enable_socket()
@pytest.hookimpl(trylast=True)
def pytest_runtest_setup() -> None:
- socket_allow_hosts(["127.0.0.1", "::1"], allow_unix_socket=True)
+ _allow_loopback_only()