mirror of
https://github.com/zensical/zensical.git
synced 2026-09-24 23:35:35 +00:00
fix: custom_dir path interpreted incorrectly on Windows (#902)
Signed-off-by: alexvoss <alex@corealization.com>
This commit is contained in:
Vendored
+18
@@ -23,6 +23,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
@@ -517,3 +518,20 @@ class TestGetThemeDir:
|
||||
def test_get_theme_dir_unknown_raises(self) -> None:
|
||||
with pytest.raises(ConfigurationError):
|
||||
get_theme_dir("definitely-not-a-real-theme-xyzzy")
|
||||
|
||||
@pytest.mark.skipif(
|
||||
os.name != "nt",
|
||||
reason="Windows-specific path normalization",
|
||||
)
|
||||
def test_custom_theme_dir_normalizes_posix_separators(
|
||||
self, tmp_path: Path
|
||||
) -> None:
|
||||
custom_dir = tmp_path / "a" / "overrides"
|
||||
custom_dir.mkdir(parents=True)
|
||||
|
||||
theme_dir = cfg_module.get_custom_theme_dir(
|
||||
"a/overrides", str(tmp_path / "mkdocs.yml")
|
||||
)
|
||||
|
||||
assert theme_dir.endswith(r"a\overrides")
|
||||
assert theme_dir == str(custom_dir)
|
||||
|
||||
@@ -304,7 +304,9 @@ def get_theme_dir(name: str) -> str:
|
||||
|
||||
def get_custom_theme_dir(path: str, config_path: str) -> str:
|
||||
"""Return the custom theme directory."""
|
||||
theme_dir = os.path.join(os.path.dirname(config_path), path)
|
||||
theme_dir = os.path.normpath(
|
||||
os.path.join(os.path.dirname(config_path), path)
|
||||
)
|
||||
|
||||
# Validate that custom theme directory exists
|
||||
if not os.path.isdir(theme_dir):
|
||||
|
||||
Reference in New Issue
Block a user