diff --git a/packages/markitdown/tests/test_module_misc.py b/packages/markitdown/tests/test_module_misc.py index 8e3acc23d..7686a74b8 100644 --- a/packages/markitdown/tests/test_module_misc.py +++ b/packages/markitdown/tests/test_module_misc.py @@ -2,6 +2,7 @@ import io import os import re +import sys import shutil import pytest from unittest.mock import MagicMock @@ -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) @@ -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