Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure shinylive assets are available for unit tests #40

Merged
merged 5 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/test_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@

import shinylive._assets


# Don't run this test in CI, unless we're triggered by a release event. In the future,
# it would make sense to run this test when we're on an rc branch.
skip_if_not_release = (
os.environ.get("CI") == "true" and os.environ.get("GITHUB_EVENT_NAME") != "release"
)


@pytest.mark.skipif(
os.environ.get("CI") == "true" and os.environ.get("GITHUB_EVENT_NAME") != "release",
skip_if_not_release,
reason="Don't run this test in CI, unless we're on a release branch.",
)
def test_assets_available():
Expand Down
28 changes: 23 additions & 5 deletions tests/test_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import pytest

from shinylive._assets import ensure_shinylive_assets


def test_requirements_txt():
from shinylive._deps import _find_packages_in_requirements
Expand All @@ -30,14 +32,18 @@ def test_requirements_txt():
# because they require the assets to be installed. In the future, it would make sense to
# run this test when we're on an rc branch.
# ======================================================================================
if os.environ.get("CI") == "true" and os.environ.get("GITHUB_EVENT_NAME") != "release":
pytest.skip(
reason="Don't run this test in CI, unless we're on a release branch.",
allow_module_level=True,
)
skip_if_not_release = (
os.environ.get("CI") == "true" and os.environ.get("GITHUB_EVENT_NAME") != "release"
)


@pytest.mark.skipif(
skip_if_not_release,
reason="Don't run this test in CI, unless we're on a release branch.",
)
def test_module_to_package_key():
ensure_shinylive_assets()

from shinylive._deps import module_to_package_key

assert module_to_package_key("cv2") == "opencv-python"
Expand All @@ -50,7 +56,13 @@ def test_module_to_package_key():
assert module_to_package_key("foobar") is None


@pytest.mark.skipif(
skip_if_not_release,
reason="Don't run this test in CI, unless we're on a release branch.",
)
def test_dep_name_to_dep_key():
ensure_shinylive_assets()

from shinylive._deps import dep_name_to_dep_key

assert dep_name_to_dep_key("black") == "black"
Expand All @@ -74,7 +86,13 @@ def test_dep_name_to_dep_key():
assert dep_name_to_dep_key("distutils") == "distutils"


@pytest.mark.skipif(
skip_if_not_release,
reason="Don't run this test in CI, unless we're on a release branch.",
)
def test_find_recursive_deps():
ensure_shinylive_assets()

from shinylive._deps import _find_recursive_deps

# It is possible that these dependencies will change in future versions of Pyodide,
Expand Down
Loading