mirror of
https://github.com/ipnet-mesh/meshcore-hub.git
synced 2026-07-05 17:31:13 +02:00
Fixed pre-commit issues
This commit is contained in:
@@ -17,36 +17,6 @@ from meshcore_hub.common.models import Base
|
||||
dotenv.load_dotenv = lambda *args, **kwargs: False
|
||||
|
||||
|
||||
def _settings_classes():
|
||||
"""CommonSettings and every subclass (recursively)."""
|
||||
seen: set[type] = set()
|
||||
stack = [config_module.CommonSettings]
|
||||
while stack:
|
||||
cls = stack.pop()
|
||||
if cls in seen:
|
||||
continue
|
||||
seen.add(cls)
|
||||
stack.extend(cls.__subclasses__())
|
||||
return seen
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _ignore_dotenv(monkeypatch):
|
||||
"""Stop pydantic-settings from reading the repo-root ``.env`` during tests.
|
||||
|
||||
Settings classes set ``env_file=".env"`` so deployments can drop a file in
|
||||
place. Tests must depend only on defaults and explicit env overrides
|
||||
(``monkeypatch.setenv``), never on whatever a developer happens to have in
|
||||
their local ``.env`` — otherwise e.g. ``DATABASE_BACKEND=postgres`` there
|
||||
leaks into unrelated tests. Each settings subclass carries its own merged
|
||||
``model_config`` dict, so patch every one.
|
||||
"""
|
||||
for cls in _settings_classes():
|
||||
cfg = dict(cls.model_config)
|
||||
cfg["env_file"] = None
|
||||
monkeypatch.setattr(cls, "model_config", cfg)
|
||||
|
||||
|
||||
def _settings_classes():
|
||||
"""CommonSettings and every subclass (recursively)."""
|
||||
seen: set[type] = set()
|
||||
|
||||
Reference in New Issue
Block a user