diff --git a/test_notebooks.py b/test_notebooks.py index 29c77ca..7cfd6d7 100644 --- a/test_notebooks.py +++ b/test_notebooks.py @@ -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(): @@ -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})" @@ -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})" @@ -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)