"""Pytest configuration file""" from pathlib import Path # Get the project root directory project_root = Path(__file__).parent.resolve() # Ignore test files that are actually scripts (not real test files) collect_ignore = [ "o11ydiagnosis/subtasks/slowlogconverter/test_query_v2.py", # Script, not a test "o11ydiagnosis/subtasks/slowlogconverter/test_task.py", # Script, not a test "o11ydiagnosis/subtasks/slowlogconverter/test_query.py", # Script with test functions but requires AWS credentials "o11ydiagnosis/subtasks/regionscompactor/test_main.py", # Script, not a test "o11ydiagnosis/serverless/test_main.py", # Script, not a test ] def pytest_ignore_collect(collection_path, config): """Ignore certain test files and virtual environment directories during collection""" # Convert to Path if it's not already if not isinstance(collection_path, Path): collection_path = Path(collection_path) path_str = str(collection_path) # Ignore virtual environment directories if '.venv' in path_str or 'venv' in path_str or 'site-packages' in path_str: return True # Ignore build directories if 'build' in path_str or '__pycache__' in path_str: return True # Only collect tests from project directory try: path_resolved = collection_path.resolve() if not str(path_resolved).startswith(str(project_root)): return True except (OSError, ValueError): # If we can't resolve the path, skip it return True # Ignore specific test files that are scripts for ignore_pattern in collect_ignore: if ignore_pattern in path_str: return True return False