From eb65a896218da54a27ce7649525e164eb90220ab Mon Sep 17 00:00:00 2001 From: Igor Ilic Date: Wed, 27 Aug 2025 12:41:13 +0200 Subject: [PATCH] fix: Resolve integration tests path issue --- .../integration/documents/PdfDocument_test.py | 4 ++-- .../integration/documents/TextDocument_test.py | 6 ++---- .../documents/UnstructuredDocument_test.py | 16 ++++++---------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/cognee/tests/integration/documents/PdfDocument_test.py b/cognee/tests/integration/documents/PdfDocument_test.py index 3e1632aac..77029e001 100644 --- a/cognee/tests/integration/documents/PdfDocument_test.py +++ b/cognee/tests/integration/documents/PdfDocument_test.py @@ -2,6 +2,7 @@ import os import sys import uuid import pytest +import pathlib from unittest.mock import patch from cognee.modules.chunking.TextChunker import TextChunker @@ -24,8 +25,7 @@ GROUND_TRUTH = [ @pytest.mark.asyncio async def test_PdfDocument(mock_engine): test_file_path = os.path.join( - os.sep, - *(os.path.dirname(__file__).split(os.sep)[:-2]), + pathlib.Path(__file__).parent.parent.parent, "test_data", "artificial-intelligence.pdf", ) diff --git a/cognee/tests/integration/documents/TextDocument_test.py b/cognee/tests/integration/documents/TextDocument_test.py index d3a624a4d..241ffe07f 100644 --- a/cognee/tests/integration/documents/TextDocument_test.py +++ b/cognee/tests/integration/documents/TextDocument_test.py @@ -2,6 +2,7 @@ import os import sys import uuid import pytest +import pathlib from unittest.mock import patch from cognee.modules.chunking.TextChunker import TextChunker @@ -34,10 +35,7 @@ GROUND_TRUTH = { @pytest.mark.asyncio async def test_TextDocument(mock_engine, input_file, chunk_size): test_file_path = os.path.join( - os.sep, - *(os.path.dirname(__file__).split(os.sep)[:-2]), - "test_data", - input_file, + pathlib.Path(__file__).parent.parent.parent, "test_data", input_file ) document = TextDocument( id=uuid.uuid4(), diff --git a/cognee/tests/integration/documents/UnstructuredDocument_test.py b/cognee/tests/integration/documents/UnstructuredDocument_test.py index 0df1987b1..114f100d5 100644 --- a/cognee/tests/integration/documents/UnstructuredDocument_test.py +++ b/cognee/tests/integration/documents/UnstructuredDocument_test.py @@ -2,6 +2,7 @@ import os import sys import uuid import pytest +import pathlib from unittest.mock import patch from cognee.modules.chunking.TextChunker import TextChunker @@ -18,31 +19,26 @@ chunk_by_sentence_module = sys.modules.get("cognee.tasks.chunks.chunk_by_sentenc async def test_UnstructuredDocument(mock_engine): # Define file paths of test data pptx_file_path = os.path.join( - os.sep, - *(os.path.dirname(__file__).split(os.sep)[:-2]), + pathlib.Path(__file__).parent.parent.parent, "test_data", "example.pptx", ) docx_file_path = os.path.join( - os.sep, - *(os.path.dirname(__file__).split(os.sep)[:-2]), + pathlib.Path(__file__).parent.parent.parent, "test_data", "example.docx", ) csv_file_path = os.path.join( - os.sep, - *(os.path.dirname(__file__).split(os.sep)[:-2]), + pathlib.Path(__file__).parent.parent.parent, "test_data", "example.csv", ) xlsx_file_path = os.path.join( - os.sep, - *(os.path.dirname(__file__).split(os.sep)[:-2]), - "test_data", - "example.xlsx", + pathlib.Path(__file__).parent.parent.parent, + "test_dataexample.xlsx", ) # Define test documents