"""packs-lab 테스트 공통 fixture.""" import pytest @pytest.fixture(autouse=True) def _hmac_secret(monkeypatch): """모든 테스트에서 동일한 HMAC secret 사용. auth._SECRET 모듈 캐시까지 갱신. test_auth.py / test_routes.py 모두 모듈 레벨에서 동일한 값을 os.environ에 직접 세팅하므로 여기서도 같은 값을 사용해 충돌 없이 일관성을 보장한다. """ secret = "test-secret-32-bytes-XXXXXXXXXXXX" monkeypatch.setenv("BACKEND_HMAC_SECRET", secret) # auth.py 모듈은 import 시점에 _SECRET을 캐시하므로 monkeypatch로 함께 갱신 from app import auth monkeypatch.setattr(auth, "_SECRET", secret)