"""Pytest configuration and fixtures"""
import pytest
import sys
from pathlib import Path
# Add project root to path
project_root = Path(__file__).parent.parent
sys.path.insert(0, str(project_root))
def pytest_addoption(parser):
"""Add custom pytest options"""
parser.addoption(
"--integration",
action="store_true",
default=False,
help="run integration tests"
)
def pytest_configure(config):
"""Configure pytest"""
config.addinivalue_line(
"markers",
"integration: mark test as an integration test requiring API access"
)
def pytest_collection_modifyitems(config, items):
"""Skip integration tests unless --integration is passed"""
if config.getoption("--integration"):
return
skip_integration = pytest.mark.skip(reason="need --integration option to run")
for item in items:
if "integration" in item.keywords:
item.add_marker(skip_integration)