"""Test configuration and fixtures.""" import os import tempfile from pathlib import Path import pytest @pytest.fixture def temp_dir(): """Create a temporary directory for tests.""" with tempfile.TemporaryDirectory() as tmp: yield Path(tmp) @pytest.fixture def project_dir(temp_dir): """Create a temporary project directory with env-pro initialized.""" profiles_dir = temp_dir / ".env-profiles" profiles_dir.mkdir() active_file = profiles_dir / ".active" active_file.write_text("default") default_profile = profiles_dir / "default" default_profile.mkdir() env_file = default_profile / ".env" env_file.write_text("") return temp_dir @pytest.fixture def sample_env_file(project_dir): """Create a sample .env file.""" env_file = project_dir / ".env-profiles" / "default" / ".env" env_file.write_text("""DATABASE_URL=postgresql://localhost:5432/db DEBUG=true SECRET_KEY=my-secret-key API_KEY= """) return env_file @pytest.fixture def mock_keyring(mocker): """Mock keyring to avoid system keyring issues.""" mocker.patch('keyring.get_password', return_value=None) mocker.patch('keyring.set_password', return_value=None)