File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,10 @@ def resolve_dependencies(
2626 if http_parent :
2727 file_or_url = parse .urljoin (http_parent , file_or_url )
2828 parsed = parse .urlparse (str (file_or_url ))
29- if parsed .scheme :
29+ # Check if it's a real URL scheme (not a Windows drive letter)
30+ # Windows drive letters are single characters, URL schemes are longer
31+ is_url = parsed .scheme and len (parsed .scheme ) > 1
32+ if is_url :
3033 with request .urlopen (str (file_or_url )) as fio :
3134 tf = tempfile .NamedTemporaryFile (
3235 suffix = ".ini" ,
@@ -54,7 +57,10 @@ def resolve_dependencies(
5457 include = include .strip ()
5558 if not include :
5659 continue
57- if http_parent or parse .urlparse (include ).scheme :
60+ # Check if it's a real URL scheme (not a Windows drive letter)
61+ parsed_include = parse .urlparse (include )
62+ is_include_url = parsed_include .scheme and len (parsed_include .scheme ) > 1
63+ if http_parent or is_include_url :
5864 file_list += resolve_dependencies (include , tmpdir , http_parent )
5965 else :
6066 file_list += resolve_dependencies (file .parent / include , tmpdir )
Original file line number Diff line number Diff line change @@ -54,3 +54,21 @@ def test_read_with_included():
5454 assert cfg ["settings" ]["unique_2" ] == "2"
5555 assert cfg ["settings" ]["unique_3" ] == "3"
5656 assert cfg ["settings" ]["unique_4" ] == "4"
57+
58+
59+ def test_resolve_dependencies_windows_path (tmp_path ):
60+ """Test that Windows absolute paths with drive letters are handled correctly.
61+
62+ On Windows, paths like 'D:\\ path\\ to\\ file.ini' should be treated as
63+ file paths, not URLs (even though urlparse() interprets 'D:' as a scheme).
64+ """
65+ from mxdev .including import resolve_dependencies
66+
67+ # Create a test file with no includes
68+ test_file = tmp_path / "test_config.ini"
69+ test_file .write_text ("[settings]\n test = value\n " )
70+
71+ # Test with the actual path (on Windows this would be like D:\...\test_config.ini)
72+ file_list = resolve_dependencies (str (test_file ), str (tmp_path ))
73+ assert len (file_list ) == 1
74+ assert file_list [0 ] == test_file
You can’t perform that action at this time.
0 commit comments