mirror of
https://github.com/Unstructured-IO/unstructured.git
synced 2025-08-12 18:54:17 +00:00

* refactor epub; add rtf * added test for rtf files * filetype detection for rtf files * add rtf to auto * update docs for group_broken_paragraphs * add rtf to docs * update file list in readme * update stage_for_transformers docs * changelog and version bump * skip rtf if in docker * skip test if rtf not supported * docs tweaks
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
import os
|
|
import pathlib
|
|
|
|
import pypandoc
|
|
import pytest
|
|
|
|
from unstructured.documents.elements import Title
|
|
from unstructured.partition.rtf import partition_rtf
|
|
|
|
DIRECTORY = pathlib.Path(__file__).parent.resolve()
|
|
|
|
rtf_not_supported = "rtf" not in pypandoc.get_pandoc_formats()[0]
|
|
is_in_docker = os.path.exists("/.dockerenv")
|
|
|
|
|
|
@pytest.mark.skipif(is_in_docker, reason="Skipping this test in Docker container")
|
|
@pytest.mark.skipif(rtf_not_supported, reason="RTF not supported in this version of pypandoc.")
|
|
def test_partition_rtf_from_filename():
|
|
filename = os.path.join(DIRECTORY, "..", "..", "example-docs", "fake-doc.rtf")
|
|
elements = partition_rtf(filename=filename)
|
|
assert len(elements) > 0
|
|
assert elements[0] == Title("My First Heading")
|
|
|
|
|
|
@pytest.mark.skipif(is_in_docker, reason="Skipping this test in Docker container")
|
|
@pytest.mark.skipif(rtf_not_supported, reason="RTF not supported in this version of pypandoc.")
|
|
def test_partition_rtf_from_file():
|
|
filename = os.path.join(DIRECTORY, "..", "..", "example-docs", "fake-doc.rtf")
|
|
with open(filename, "rb") as f:
|
|
elements = partition_rtf(file=f)
|
|
assert len(elements) > 0
|
|
assert elements[0] == Title("My First Heading")
|