Spaces:
Running
Running
File size: 1,905 Bytes
9f2df60 7feef55 9f2df60 7feef55 9f2df60 31c360c 9f2df60 7feef55 9f2df60 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | from __future__ import annotations
import importlib.util
import sys
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parents[1]
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
TEST_DEPENDENCIES = {
"tests/consent/test_agent_chain_session.py": {"langchain_core", "langchain", "langsmith"},
"tests/consent/test_consent_logger.py": {"colorama"},
"tests/scraping/test_happy_path.py": {"colorama", "docling", "docling_core", "usp", "fake_useragent", "tiktoken"},
"tests/scraping/test_page_chunking.py": {"colorama", "docling", "docling_core", "tiktoken"},
"tests/scraping/test_scraping.py": {"colorama", "docling_core", "usp", "fake_useragent", "tiktoken"},
"tests/scraping/test_scraping_resume.py": {"colorama", "docling_core", "usp", "fake_useragent", "tiktoken"},
"tests/scraping/test_utils.py": {"fake_useragent"},
"tests/test_chatbot_improvements.py": {"langchain_core", "langchain", "langsmith"},
"tests/test_language_handling.py": {"langchain_core"},
"tests/test_programme_positioning_real_agent.py": {"langchain_core", "langchain", "langsmith", "weaviate"},
"tests/test_reply_speed_real_agent.py": {"langchain_core", "langchain", "langsmith", "weaviate"},
"tests/test_uat_llm_judge.py": {"openpyxl", "openai", "langchain_core", "langchain", "langsmith", "weaviate"},
"tests/test_weaviate_connection.py": {"langchain_core", "langchain", "colorama"},
}
def _missing_dependency(module_name: str) -> bool:
return importlib.util.find_spec(module_name) is None
def pytest_ignore_collect(collection_path: Path, config) -> bool:
rel_path = collection_path.relative_to(Path(config.rootpath)).as_posix()
required_modules = TEST_DEPENDENCIES.get(rel_path)
if not required_modules:
return False
return any(_missing_dependency(module_name) for module_name in required_modules)
|