mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-25 01:02:15 +00:00
ci(tests): share the loopback allow list in the unit conftest
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
446bd1b250
commit
df7a3d2d1e
1 changed files with 9 additions and 2 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue