PYTHON
conftest.py🐍python
"""
Pytest configuration and fixtures for sync tests.
"""
import pytest
import asyncio
import tempfile
import os
from pathlib import Path
@pytest.fixture(scope="session")
def event_loop():
"""Create an event loop for async tests."""
loop = asyncio.get_event_loop_policy().new_event_loop()
yield loop
loop.close()
@pytest.fixture
def temp_source_dir(tmp_path):
"""Create a temporary source directory with test files."""
source_dir = tmp_path / "source"
source_dir.mkdir()
# Create some test files
(source_dir / "file1.txt").write_text("Hello, World!")
(source_dir / "file2.txt").write_text("Test content")
# Create subdirectory
sub_dir = source_dir / "subdir"
sub_dir.mkdir()
(sub_dir / "nested.txt").write_text("Nested file content")
return source_dir
@pytest.fixture
def temp_backup_dir(tmp_path):
"""Create a temporary backup directory."""
backup_dir = tmp_path / "backup"
backup_dir.mkdir()
return backup_dir
@pytest.fixture
def sample_file(tmp_path):
"""Create a sample file for testing."""
file_path = tmp_path / "sample.txt"
file_path.write_text("This is sample content for testing.")
return file_path