From b7b8d156325a70f45f7b44580ce004388ec5a796 Mon Sep 17 00:00:00 2001 From: yangdx Date: Mon, 17 Nov 2025 23:52:13 +0800 Subject: [PATCH] Refactor pytest dependencies into separate optional group - Extract pytest deps to own group - Reference pytest group in evaluation - Add pytest config to pyproject.toml - Update uv.lock with new structure --- pyproject.toml | 18 ++++++++++++++++-- uv.lock | 11 ++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3c7450f4..1465c641 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,12 @@ dependencies = [ ] [project.optional-dependencies] +# Test framework dependencies (for CI/CD and testing) +pytest = [ + "pytest>=8.4.2", + "pytest-asyncio>=1.2.0", +] + api = [ # Core dependencies "aiohttp", @@ -125,12 +131,12 @@ offline = [ ] evaluation = [ + # Test framework (reference pytest group) + "lightrag-hku[pytest]", # RAG evaluation dependencies (RAGAS framework) "ragas>=0.3.7", "datasets>=4.3.0", "httpx>=0.28.1", - "pytest>=8.4.2", - "pytest-asyncio>=1.2.0", ] observability = [ @@ -162,5 +168,13 @@ version = {attr = "lightrag.__version__"} [tool.setuptools.package-data] lightrag = ["api/webui/**/*", "api/static/**/*"] +[tool.pytest.ini_options] +asyncio_mode = "auto" +asyncio_default_fixture_loop_scope = "function" +testpaths = ["tests"] +python_files = ["test_*.py"] +python_classes = ["Test*"] +python_functions = ["test_*"] + [tool.ruff] target-version = "py310" diff --git a/uv.lock b/uv.lock index 6408bd92..5b86567e 100644 --- a/uv.lock +++ b/uv.lock @@ -2695,6 +2695,10 @@ offline-storage = [ { name = "qdrant-client", version = "1.15.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.13'" }, { name = "redis" }, ] +pytest = [ + { name = "pytest" }, + { name = "pytest-asyncio" }, +] [package.metadata] requires-dist = [ @@ -2729,6 +2733,7 @@ requires-dist = [ { name = "json-repair", marker = "extra == 'api'" }, { name = "langfuse", marker = "extra == 'observability'", specifier = ">=3.8.1" }, { name = "lightrag-hku", extras = ["api", "offline-llm", "offline-storage"], marker = "extra == 'offline'" }, + { name = "lightrag-hku", extras = ["pytest"], marker = "extra == 'evaluation'" }, { name = "llama-index", marker = "extra == 'offline-llm'", specifier = ">=0.9.0,<1.0.0" }, { name = "nano-vectordb" }, { name = "nano-vectordb", marker = "extra == 'api'" }, @@ -2756,8 +2761,8 @@ requires-dist = [ { name = "pypdf", marker = "extra == 'api'", specifier = ">=6.1.0" }, { name = "pypinyin" }, { name = "pypinyin", marker = "extra == 'api'" }, - { name = "pytest", marker = "extra == 'evaluation'", specifier = ">=8.4.2" }, - { name = "pytest-asyncio", marker = "extra == 'evaluation'", specifier = ">=1.2.0" }, + { name = "pytest", marker = "extra == 'pytest'", specifier = ">=8.4.2" }, + { name = "pytest-asyncio", marker = "extra == 'pytest'", specifier = ">=1.2.0" }, { name = "python-docx", marker = "extra == 'api'", specifier = ">=0.8.11,<2.0.0" }, { name = "python-dotenv" }, { name = "python-dotenv", marker = "extra == 'api'" }, @@ -2780,7 +2785,7 @@ requires-dist = [ { name = "xlsxwriter", marker = "extra == 'api'", specifier = ">=3.1.0" }, { name = "zhipuai", marker = "extra == 'offline-llm'", specifier = ">=2.0.0,<3.0.0" }, ] -provides-extras = ["api", "docling", "offline-storage", "offline-llm", "offline", "evaluation", "observability"] +provides-extras = ["pytest", "api", "docling", "offline-storage", "offline-llm", "offline", "evaluation", "observability"] [[package]] name = "llama-cloud"