Skip to content

Commit

Permalink
fix path function for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Agnieszka Żaba committed Oct 16, 2024
1 parent bf916b5 commit de5e405
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


def _relative_path(absolute_path):
return os.path.relpath(absolute_path, _repo_path().absolute())
return os.path.normpath(os.path.relpath(absolute_path, _repo_path().absolute()))


def _repo_path():
Expand Down Expand Up @@ -111,7 +111,7 @@ def _preview_badge_markdown(absolute_path):
)
link = (
f"https://github.com/open-atmos/{_repo_path().name}/blob/main/"
+ f"{pathlib.PurePath(_relative_path(absolute_path))}"
+ f"{_relative_path(absolute_path)}"
)
return f"[![preview notebook]({svg_badge_url})]({link})"

Expand All @@ -120,7 +120,7 @@ def _mybinder_badge_markdown(abslute_path):
svg_badge_url = "https://mybinder.org/badge_logo.svg"
link = (
f"https://mybinder.org/v2/gh/open-atmos/{_repo_path().name}.git/main?urlpath=lab/tree/"
+ f"{pathlib.PurePath(_relative_path(abslute_path))}"
+ f"{_relative_path(abslute_path)}"
)
return f"[![launch on mybinder.org]({svg_badge_url})]({link})"

Expand All @@ -129,13 +129,13 @@ def _colab_badge_markdown(absolute_path):
svg_badge_url = "https://colab.research.google.com/assets/colab-badge.svg"
link = (
f"https://colab.research.google.com/github/open-atmos/{_repo_path().name}/blob/main/"
+ f"{pathlib.PurePath(_relative_path(absolute_path))}"
+ f"{_relative_path(absolute_path)}"
)
return f"[![launch on Colab]({svg_badge_url})]({link})"


def test_first_cell_contains_three_badges(notebook_filename):
"""checks if all notebooks feature preview, mybinder and Colab badges
"""checks if all notebooks feature nbviewer, mybinder and Colab badges
(in the first cell)"""
with open(notebook_filename, encoding="utf8") as fp:
nb = nbformat.read(fp, nbformat.NO_CONVERT)
Expand Down

0 comments on commit de5e405

Please sign in to comment.