Disable rate_limit_redis_enabled in test fixtures
The rate-limit middleware creates a Redis client at module import time when rate_limit_redis_enabled is true. The conftest disables rate_limit_enabled but not the redis flag, so the client still gets created. After the test event loop closes, the client's async disconnect raises 'Event loop is closed', surfacing as 500s on test_validation_error_returns_422_with_field_errors and test_error_stats_with_valid_key. Setting rate_limit_redis_enabled=False in the autouse fixture prevents the Redis client from being created in the first place. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -142,8 +142,10 @@ TEST_DATABASE_URL = "sqlite+aiosqlite:///:memory:"
|
||||
def disable_rate_limiting():
|
||||
"""Disable rate limiting for all tests to prevent 429 interference."""
|
||||
cartsnitch_settings.rate_limit_enabled = False
|
||||
cartsnitch_settings.rate_limit_redis_enabled = False
|
||||
yield
|
||||
cartsnitch_settings.rate_limit_enabled = True
|
||||
cartsnitch_settings.rate_limit_redis_enabled = True
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in New Issue
Block a user