Skip to content

Commit

Permalink
Fix rel path tests for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
gudzpoz committed Jan 17, 2025
1 parent fbbd767 commit 9250b10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions nikola/nikola.py
Original file line number Diff line number Diff line change
Expand Up @@ -1971,7 +1971,7 @@ def filename_path(self, name, _lang):
link://filename/manual.txt => /docs/handbook.html
"""
results = [p for p in self.timeline if p.source_path == name]
results = [p for p in self.timeline if os.path.samefile(p.source_path, name)]
if results:
if len(results) > 1:
utils.LOGGER.error("Ambiguous path request for filename: {0}".format(name))
Expand All @@ -1980,7 +1980,7 @@ def filename_path(self, name, _lang):
results = self.timeline
for p in results:
for lang in p.translated_to:
if p.translated_source_path(lang) == name:
if os.path.samefile(p.translated_source_path(lang), name):
return [_f for _f in p.permalink(lang).split('/') if _f]
utils.LOGGER.warning("Cannot resolve path request for filename: {0}".format(name))

Expand Down
9 changes: 6 additions & 3 deletions tests/integration/test_translated_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ def test_translated_cross_links(build, output_dir, other_locale):
href = link.get("href")
if text in expected:
link_count += 1
dest = os.path.join(os.path.dirname(f), href)
rel = os.path.relpath(dest, output_dir).strip('/')
assert rel == expected[text]
dest = os.path.join(
output_dir if href.startswith("/") else os.path.dirname(f),
href,
)
rel = os.path.relpath(dest, output_dir).strip("/").replace("\\", "/")
assert rel == expected[text], (f, text, href)
assert link_count == len(expected)


Expand Down

0 comments on commit 9250b10

Please sign in to comment.