""" Pytest configuration and shared fixtures. """ import os import pytest @pytest.fixture(scope="session", autouse=True) def setup_test_config(): """ Setup test configuration before any tests run. This ensures required environment variables are set for test execution. """ # Set required configuration os.environ.setdefault("GONDULF_SECRET_KEY", "test-secret-key-for-testing-only-32chars") os.environ.setdefault("GONDULF_BASE_URL", "http://localhost:8000") os.environ.setdefault("GONDULF_DEBUG", "true") os.environ.setdefault("GONDULF_DATABASE_URL", "sqlite:///:memory:") @pytest.fixture(autouse=True) def reset_config_before_test(monkeypatch): """ Reset configuration before each test. This prevents config from one test affecting another test. """ # Clear all GONDULF_ environment variables gondulf_vars = [key for key in os.environ.keys() if key.startswith("GONDULF_")] for var in gondulf_vars: monkeypatch.delenv(var, raising=False) # Re-set required test configuration monkeypatch.setenv("GONDULF_SECRET_KEY", "test-secret-key-for-testing-only-32chars") monkeypatch.setenv("GONDULF_BASE_URL", "http://localhost:8000") monkeypatch.setenv("GONDULF_DEBUG", "true") monkeypatch.setenv("GONDULF_DATABASE_URL", "sqlite:///:memory:")