WIP: code cleanup
This commit is contained in:
30
vibe_bot/tests/conftest.py
Normal file
30
vibe_bot/tests/conftest.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
import pytest
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Try to load .env.test first, fallback to .env
|
||||
env_test_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env.test')
|
||||
env_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env')
|
||||
|
||||
if os.path.exists(env_test_path):
|
||||
load_dotenv(env_test_path)
|
||||
print("✓ Loaded environment variables from .env.test")
|
||||
elif os.path.exists(env_path):
|
||||
load_dotenv(env_path)
|
||||
print("✓ Loaded environment variables from .env")
|
||||
|
||||
@pytest.fixture(autouse=True, scope="session")
|
||||
def verify_env_loaded():
|
||||
"""Verify critical environment variables are loaded before tests run"""
|
||||
required_vars = [
|
||||
"DISCORD_TOKEN",
|
||||
"OPENAI_API_ENDPOINT",
|
||||
"IMAGE_GEN_ENDPOINT",
|
||||
"IMAGE_EDIT_ENDPOINT"
|
||||
]
|
||||
|
||||
missing_vars = [var for var in required_vars if var not in os.environ]
|
||||
if missing_vars:
|
||||
pytest.fail(f"Missing required environment variables: {', '.join(missing_vars)}")
|
||||
|
||||
yield
|
||||
Reference in New Issue
Block a user