Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions packages/markitdown/tests/test_module_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import io
import os
import re
import sys
import shutil
import pytest
from unittest.mock import MagicMock
Expand Down Expand Up @@ -219,8 +220,8 @@ def test_data_uris() -> None:
assert attributes["charset"] == "utf-8"
assert data == b"Hello, World!"


def test_file_uris() -> None:
@pytest.mark.skipif(sys.platform == "win32", reason="POSIX-specific test")
def test_file_uris_posix() -> None:
# Test file URI with an empty host
file_uri = "file:///path/to/file.txt"
netloc, path = file_uri_to_path(file_uri)
Expand Down Expand Up @@ -251,6 +252,37 @@ def test_file_uris() -> None:
assert netloc is None
assert path == "/path/to/file.txt"

@pytest.mark.skipif(sys.platform != "win32", reason="Windows-specific test")
def test_file_uris_windows() -> None:
# Test file URI with an empty host
file_uri = "file:///C:/path/to/file.txt"
netloc, path = file_uri_to_path(file_uri)
assert netloc is None
assert path == "C:\\path\\to\\file.txt"

# Test file URI with no host
file_uri = "file:/C:/path/to/file.txt"
netloc, path = file_uri_to_path(file_uri)
assert netloc is None
assert path == "C:\\path\\to\\file.txt"

# Test file URI with localhost
file_uri = "file://localhost/C:/path/to/file.txt"
netloc, path = file_uri_to_path(file_uri)
assert netloc == "localhost"
assert path == "C:\\path\\to\\file.txt"

# Test file URI with query parameters
file_uri = "file:///C:/path/to/file.txt?param=value"
netloc, path = file_uri_to_path(file_uri)
assert netloc is None
assert path == "C:\\path\\to\\file.txt"

# Test file URI with fragment
file_uri = "file:///C:/path/to/file.txt#fragment"
netloc, path = file_uri_to_path(file_uri)
assert netloc is None
assert path == "C:\\path\\to\\file.txt"

def test_docx_comments() -> None:
# Test DOCX processing, with comments and setting style_map on init
Expand Down