Skip to content

Commit

Permalink
fix: avoid "test" prefix in test util fn
Browse files Browse the repository at this point in the history
  • Loading branch information
scanny committed Dec 9, 2024
1 parent f2cafbd commit 7c6c8e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions test_unstructured/chunking/test_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import pytest

from test_unstructured.unit_utils import FixtureRequest, Mock, function_mock, testfile_path
from test_unstructured.unit_utils import FixtureRequest, Mock, function_mock, input_path
from unstructured.chunking.base import CHUNK_MULTI_PAGE_DEFAULT
from unstructured.chunking.title import _ByTitleChunkingOptions, chunk_by_title
from unstructured.documents.coordinates import CoordinateSystem
Expand Down Expand Up @@ -36,7 +36,7 @@


def test_it_chunks_text_followed_by_table_together_when_both_fit():
elements = elements_from_json(testfile_path("chunking/title_table_200.json"))
elements = elements_from_json(input_path("chunking/title_table_200.json"))

chunks = chunk_by_title(elements, combine_text_under_n_chars=0)

Expand All @@ -45,7 +45,7 @@ def test_it_chunks_text_followed_by_table_together_when_both_fit():


def test_it_chunks_table_followed_by_text_together_when_both_fit():
elements = elements_from_json(testfile_path("chunking/table_text_200.json"))
elements = elements_from_json(input_path("chunking/table_text_200.json"))

# -- disable chunk combining so we test pre-chunking behavior, not chunk-combining --
chunks = chunk_by_title(elements, combine_text_under_n_chars=0)
Expand All @@ -55,7 +55,7 @@ def test_it_chunks_table_followed_by_text_together_when_both_fit():


def test_it_splits_oversized_table():
elements = elements_from_json(testfile_path("chunking/table_2000.json"))
elements = elements_from_json(input_path("chunking/table_2000.json"))

chunks = chunk_by_title(elements)

Expand All @@ -64,7 +64,7 @@ def test_it_splits_oversized_table():


def test_it_starts_new_chunk_for_table_after_full_text_chunk():
elements = elements_from_json(testfile_path("chunking/long_text_table_200.json"))
elements = elements_from_json(input_path("chunking/long_text_table_200.json"))

chunks = chunk_by_title(elements, max_characters=250)

Expand All @@ -73,7 +73,7 @@ def test_it_starts_new_chunk_for_table_after_full_text_chunk():


def test_it_starts_new_chunk_for_text_after_full_table_chunk():
elements = elements_from_json(testfile_path("chunking/full_table_long_text_250.json"))
elements = elements_from_json(input_path("chunking/full_table_long_text_250.json"))

chunks = chunk_by_title(elements, max_characters=250)

Expand Down
2 changes: 1 addition & 1 deletion test_unstructured/unit_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def parse_optional_datetime(datetime_str: Optional[str]) -> Optional[dt.datetime
return dt.datetime.fromisoformat(datetime_str) if datetime_str else None


def testfile_path(rel_path: str) -> str:
def input_path(rel_path: str) -> str:
"""Resolve the absolute-path to `rel_path` in the testfiles directory."""
testfiles_dir = pathlib.Path(__file__).parent / "testfiles"
file_path = testfiles_dir / rel_path
Expand Down

0 comments on commit 7c6c8e0

Please sign in to comment.