"""Own regression suite respects the real shared login budget; teacher client unchanged.""" import time import pytest from client import Client _paced_logins = 0 @pytest.fixture(scope="session", autouse=True) def honor_login_retry_after(): original = Client.call def paced( self, method, path, expected=200, body=None, actor=None, headers=None, raw=None, schema=None ): global _paced_logins if method != "POST" or path != "/api/v1/auth/sessions" or expected != 201: return original(self, method, path, expected, body, actor, headers, raw, schema) deadline = time.monotonic() + 90 while True: response = original(self, method, path, [201, 429], body, actor, headers, raw, schema) if response["status"] == 201: return response if time.monotonic() >= deadline: pytest.fail("Shared login budget did not recover within test deadline") _paced_logins += 1 time.sleep(min(10, max(1, float(response["headers"].get("Retry-After", "10"))))) Client.call = paced yield Client.call = original def pytest_terminal_summary(terminalreporter): terminalreporter.write_line( f"Login pacing: {_paced_logins} retries honoring runtime Retry-After; teacher client unchanged." )