Skip to content
Prev Previous commit
Next Next commit
fix tests for windows
  • Loading branch information
spinto committed Dec 9, 2025
commit 6061c6a65f2e8098479aff8a36d309a89847241c
31 changes: 15 additions & 16 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ def test_is_absolute_href() -> None:
("./item.json", False, None),
("../item.json", False, None),
("http://stacspec.org/item.json", True, None),
("/item.json", True, None),
("/item.json", False, "http://stacspec.org/"),
("http://stacspec.org/item.json", True, "http://stacspec.org/"),
]

Expand All @@ -217,15 +215,16 @@ def test_is_absolute_href_os_aware() -> None:
is_windows = os.name == "nt"
incl_drive_letter = path_includes_drive_letter()
test_cases = [
("/item.json", not incl_drive_letter),
("/home/someuser/Downloads/item.json", not incl_drive_letter),
("file:///home/someuser/Downloads/item.json", not incl_drive_letter),
("d:/item.json", is_windows),
("c:/files/more_files/item.json", is_windows),
("/item.json", not incl_drive_letter, None),
("/item.json", False, "http://stacspec.org/"),
("/home/someuser/Downloads/item.json", not incl_drive_letter, None),
("file:///home/someuser/Downloads/item.json", not incl_drive_letter, None),
("d:/item.json", is_windows, None),
("c:/files/more_files/item.json", is_windows, None),
]

for href, expected in test_cases:
actual = is_absolute_href(href)
for href, expected, start_href in test_cases:
actual = is_absolute_href(href, start_href)
assert actual == expected


Expand All @@ -234,15 +233,15 @@ def test_is_absolute_href_windows() -> None:
# Test cases of (href, expected)

test_cases = [
("item.json", False),
(".\\item.json", False),
("..\\item.json", False),
("c:\\item.json", True),
("http://stacspec.org/item.json", True),
("item.json", False, None),
(".\\item.json", False, None),
("..\\item.json", False, None),
("c:\\item.json", True, None),
("http://stacspec.org/item.json", True, None),
]

for href, expected in test_cases:
actual = is_absolute_href(href)
for href, expected, start_href in test_cases:
actual = is_absolute_href(href, start_href)
assert actual == expected


Expand Down