Skip to content

Commit 7fc1db2

Browse files
committed
Fix missing DEVIL_API_KEY in tests
1 parent d00cd01 commit 7fc1db2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/conftest.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
from __future__ import annotations
22

3+
import importlib
34
import os
45
import sys
56
from pathlib import Path
67

78
import pytest
89

9-
from app.auth import AUTH_FAILURE_TRACKER
10-
11-
# Ensure project root (where 'app' package resides) is on sys.path
10+
# Adjust sys.path early so subsequent imports resolve
1211
ROOT = Path(__file__).resolve().parent.parent
1312
if str(ROOT) not in sys.path:
1413
sys.path.insert(0, str(ROOT))
1514

16-
# Provide default API key for any imports needing it
15+
# Provide default API key before importing modules that validate it at import time
1716
os.environ.setdefault("DEVIL_API_KEY", "devil")
1817

18+
# Lazy import after env var is ensured while keeping all import statements grouped at the top
19+
AUTH_FAILURE_TRACKER = importlib.import_module("app.auth").AUTH_FAILURE_TRACKER
20+
1921

2022
@pytest.fixture(autouse=True)
2123
def reset_auth_tracker():

0 commit comments

Comments
 (0)