"""Pytest configuration and fixtures. This module contains shared fixtures and configuration for all tests. """ import sys import os import pytest import pytest_asyncio # Add src to path for importing in tests sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src')) # Markers for test organization pytest_plugins = ['pytest_asyncio'] def pytest_configure(config): """Configure pytest with custom markers.""" config.addinivalue_line("markers", "unit: Unit tests (no external dependencies)") config.addinivalue_line("markers", "integration: Integration tests (with mocked dependencies)") config.addinivalue_line("markers", "e2e: End-to-end tests (full workflow)") config.addinivalue_line("markers", "slow: Slow tests (skip in quick mode)") @pytest.fixture(scope='session') def project_root(): """Return the project root directory.""" return os.path.dirname(os.path.dirname(__file__)) @pytest.fixture(scope='session') def src_path(project_root): """Return the src directory path.""" return os.path.join(project_root, 'src') @pytest.fixture def temp_dir(tmp_path): """Provide a temporary directory for tests.""" return tmp_path @pytest.fixture def mock_env_vars(monkeypatch): """Set up mock environment variables for testing.""" monkeypatch.setenv('SECRET_KEY', 'test-secret-key-min-32-characters-long') monkeypatch.setenv('ENCRYPTION_KEY', 'test-32-byte-encryption-key!!') monkeypatch.setenv('DATABASE_URL', 'sqlite:///./test.db') monkeypatch.setenv('DEBUG', 'true') monkeypatch.setenv('LOG_LEVEL', 'DEBUG')