mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-17 09:34:48 +00:00
test(unit): fall back to /tmp when TMPDIR leaves no room for a socket path
socket_dir now uses /tmp when TMPDIR plus the longest socket suffix would pass macOS's sun_path limit, and its teardown ignores errors so a failed test reports only its own failure
This commit is contained in:
parent
278386f3b3
commit
96c8a54154
2 changed files with 11 additions and 3 deletions
|
|
@ -219,12 +219,21 @@ def _flush_client_caches() -> None:
|
|||
_reset_aws_auth_caches()
|
||||
|
||||
|
||||
_MACOS_LONGEST_SOCKET_PATH: Final = 103
|
||||
_LONGEST_SOCKET_SUFFIX: Final = len("/sock12345678/.s.PGSQL.65535")
|
||||
|
||||
|
||||
def _socket_root() -> str:
|
||||
default: Final = tempfile.gettempdir()
|
||||
return default if len(default) + _LONGEST_SOCKET_SUFFIX <= _MACOS_LONGEST_SOCKET_PATH else "/tmp"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def socket_dir() -> Iterator[Path]:
|
||||
"""A directory whose unix socket paths fit the kernel's sun_path limit, which pytest's tmp_path exceeds on macOS."""
|
||||
directory: Final = Path(tempfile.mkdtemp(prefix="sock"))
|
||||
directory: Final = Path(tempfile.mkdtemp(prefix="sock", dir=_socket_root()))
|
||||
yield directory
|
||||
shutil.rmtree(directory)
|
||||
shutil.rmtree(directory, ignore_errors=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import os
|
|||
import tempfile
|
||||
import warnings
|
||||
from collections.abc import Awaitable, Callable, Iterator
|
||||
from pathlib import Path
|
||||
from typing import Dict, Final, Optional
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue