Buckets:

download
raw
1.17 kB
"""API fixtures for tests."""
import socket
import pytest
@pytest.fixture
def random_api_port():
"""Get a random available port for API testing."""
# Find an available port
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
# Bind to localhost only for tests (not all interfaces)
s.bind(("127.0.0.1", 0))
s.listen(1)
port = s.getsockname()[1]
# Port is now released and should be available
# There's a small race condition here, but it's acceptable for tests
return port
@pytest.fixture(scope="session")
def session_api_port():
"""Get a session-scoped random available port for API testing."""
# Find an available port
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
# Bind to localhost only for tests (not all interfaces)
s.bind(("127.0.0.1", 0))
s.listen(1)
port = s.getsockname()[1]
# Port is now released and should be available
# There's a small race condition here, but it's acceptable for tests
return port
@pytest.fixture
def free_api_port():
"""Alternative name for random_api_port."""
return random_api_port()

Xet Storage Details

Size:
1.17 kB
·
Xet hash:
6528eb44c5620d4564fbfbd1c89a0e5479d8e9c2a1da0be819262576543b0f48

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.