style: apply ruff formatting and move TYPE_CHECKING imports in tests

This commit is contained in:
2026-02-04 01:08:32 +00:00
parent d7966f7e96
commit fc88f84f4a
6 changed files with 53 additions and 66 deletions

View File

@@ -13,13 +13,16 @@ Comprehensive tests covering:
from __future__ import annotations
import asyncio
from typing import AsyncGenerator
from typing import TYPE_CHECKING
import pytest
from fastapi_traffic.backends.memory import MemoryBackend
from fastapi_traffic.backends.sqlite import SQLiteBackend
if TYPE_CHECKING:
from collections.abc import AsyncGenerator
@pytest.mark.asyncio
class TestMemoryBackend:
@@ -163,6 +166,7 @@ class TestMemoryBackendAdvanced:
"""Test concurrent write operations don't corrupt data."""
backend = MemoryBackend(max_size=1000)
try:
async def write_key(i: int) -> None:
await backend.set(f"key_{i}", {"value": i}, ttl=60.0)
@@ -302,6 +306,7 @@ class TestSQLiteBackendAdvanced:
backend = SQLiteBackend(":memory:")
await backend.initialize()
try:
async def write_key(i: int) -> None:
await backend.set(f"key_{i}", {"value": i}, ttl=60.0)
@@ -377,7 +382,9 @@ class TestBackendInterface:
"""Tests to verify backend interface consistency."""
@pytest.fixture
async def backends(self) -> AsyncGenerator[list[MemoryBackend | SQLiteBackend], None]:
async def backends(
self,
) -> AsyncGenerator[list[MemoryBackend | SQLiteBackend], None]:
"""Create all backend types for testing."""
memory = MemoryBackend()
sqlite = SQLiteBackend(":memory:")