Reset GlobalState and ServerState before each test to ensure isolation.
()
| 27 | |
| 28 | @pytest.fixture(autouse=True) |
| 29 | def reset_global_state(): |
| 30 | """Reset GlobalState and ServerState before each test to ensure isolation.""" |
| 31 | from api_utils.server_state import state |
| 32 | from config.global_state import GlobalState |
| 33 | |
| 34 | GlobalState.reset_quota_status() |
| 35 | GlobalState.IS_RECOVERING = False |
| 36 | GlobalState.DEPLOYMENT_EMERGENCY_MODE = False |
| 37 | GlobalState.CURRENT_STREAM_REQ_ID = None |
| 38 | GlobalState.queued_request_count = 0 |
| 39 | GlobalState.AUTH_ROTATION_LOCK.set() # Allow requests by default |
| 40 | GlobalState.QUOTA_EXCEEDED_EVENT.clear() |
| 41 | GlobalState.rotation_complete_event.clear() |
| 42 | GlobalState.RECOVERY_EVENT.set() |
| 43 | GlobalState.IS_SHUTTING_DOWN.clear() |
| 44 | |
| 45 | state.reset() |
| 46 | yield |
| 47 | |
| 48 | |
| 49 | @pytest.fixture(autouse=True) |
nothing calls this directly
no test coverage detected