From 8c7843a49e10202409f0d41e80fc51020c8b6e60 Mon Sep 17 00:00:00 2001 From: AkhileshNegi Date: Wed, 14 Jan 2026 18:01:32 +0530 Subject: [PATCH] fix: move crawler fixture to conftest.py for proper pytest discovery The crawler fixture was being imported directly in test files, which linters flagged as an "unused import" since fixtures aren't explicitly called. This led to accidental removal and test failures. Moving the fixture to a conftest.py file follows pytest best practices for fixture discovery and avoids lint false positives. Co-Authored-By: Claude Opus 4.5 --- backend/app/tests/api/routes/documents/conftest.py | 11 +++++++++++ .../api/routes/documents/test_route_document_info.py | 1 - .../api/routes/documents/test_route_document_list.py | 1 - .../documents/test_route_document_permanent_remove.py | 3 +-- backend/app/tests/utils/document.py | 6 ------ 5 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 backend/app/tests/api/routes/documents/conftest.py diff --git a/backend/app/tests/api/routes/documents/conftest.py b/backend/app/tests/api/routes/documents/conftest.py new file mode 100644 index 00000000..d36dc181 --- /dev/null +++ b/backend/app/tests/api/routes/documents/conftest.py @@ -0,0 +1,11 @@ +import pytest +from starlette.testclient import TestClient + +from app.tests.utils.auth import TestAuthContext +from app.tests.utils.document import WebCrawler + + +@pytest.fixture +def crawler(client: TestClient, user_api_key: TestAuthContext) -> WebCrawler: + """Provides a WebCrawler instance for document API testing.""" + return WebCrawler(client, user_api_key=user_api_key) diff --git a/backend/app/tests/api/routes/documents/test_route_document_info.py b/backend/app/tests/api/routes/documents/test_route_document_info.py index 5e6680b1..26198348 100644 --- a/backend/app/tests/api/routes/documents/test_route_document_info.py +++ b/backend/app/tests/api/routes/documents/test_route_document_info.py @@ -7,7 +7,6 @@ DocumentStore, Route, WebCrawler, - crawler, httpx_to_standard, ) diff --git a/backend/app/tests/api/routes/documents/test_route_document_list.py b/backend/app/tests/api/routes/documents/test_route_document_list.py index 9f4290c8..01a5e2ed 100644 --- a/backend/app/tests/api/routes/documents/test_route_document_list.py +++ b/backend/app/tests/api/routes/documents/test_route_document_list.py @@ -6,7 +6,6 @@ DocumentStore, Route, WebCrawler, - crawler, httpx_to_standard, ) diff --git a/backend/app/tests/api/routes/documents/test_route_document_permanent_remove.py b/backend/app/tests/api/routes/documents/test_route_document_permanent_remove.py index 7907e988..b0f02305 100644 --- a/backend/app/tests/api/routes/documents/test_route_document_permanent_remove.py +++ b/backend/app/tests/api/routes/documents/test_route_document_permanent_remove.py @@ -16,11 +16,10 @@ from app.core.config import settings from app.models import Document from app.tests.utils.document import ( - DocumentStore, DocumentMaker, + DocumentStore, Route, WebCrawler, - crawler, ) diff --git a/backend/app/tests/utils/document.py b/backend/app/tests/utils/document.py index e339c1a0..bcb8b75f 100644 --- a/backend/app/tests/utils/document.py +++ b/backend/app/tests/utils/document.py @@ -7,7 +7,6 @@ from dataclasses import dataclass from urllib.parse import ParseResult, urlunparse -import pytest from httpx import Response from sqlmodel import Session, delete from fastapi.testclient import TestClient @@ -164,8 +163,3 @@ def to_public_dict(self) -> dict: result[field] = self.to_string(value) return result - - -@pytest.fixture -def crawler(client: TestClient, user_api_key: TestAuthContext) -> WebCrawler: - return WebCrawler(client, user_api_key=user_api_key)