Reuse `skip_unless_executable` test decorator for conda and singularity

This commit is contained in:
Nicola Soranzo
2023-06-02 16:10:28 +01:00
parent 4579c3bc2c
commit a04ce55f03
4 changed files with 22 additions and 18 deletions
@@ -5,8 +5,11 @@ from typing import (
)
from unittest import SkipTest
import pytest
import requests
from galaxy.util.commands import which
def is_site_up(url: str) -> bool:
try:
@@ -30,3 +33,13 @@ def skip_if_site_down(url: str) -> Callable:
skip_if_github_down = skip_if_site_down("https://github.com/")
def _identity(func: Callable) -> Callable:
return func
def skip_unless_executable(executable):
if which(executable):
return _identity
return pytest.mark.skip(f"PATH doesn't contain executable {executable}")
+4 -11
View File
@@ -24,8 +24,11 @@ import pytest
from galaxy.app import UniverseApplication
from galaxy.tool_util.verify.test_data import TestDataResolver
from galaxy.util import safe_makedirs
from galaxy.util.commands import which
from galaxy.util.unittest import TestCase
from galaxy.util.unittest_utils import (
_identity,
skip_unless_executable,
)
from galaxy_test.base.api import (
UsesApiTestCaseMixin,
UsesCeleryTasks,
@@ -43,10 +46,6 @@ SCRIPT_DIRECTORY = os.path.abspath(os.path.dirname(__file__))
VAULT_CONF = os.path.join(SCRIPT_DIRECTORY, "vault_conf.yml")
def _identity(func):
return func
def skip_if_jenkins(cls):
if os.environ.get("BUILD_NUMBER", ""):
return skip
@@ -66,12 +65,6 @@ def skip_unless_postgres():
return pytest.mark.skip("GALAXY_TEST_DBURI does not point to postgres database, required for this test.")
def skip_unless_executable(executable):
if which(executable):
return _identity
return pytest.mark.skip(f"PATH doesn't contain executable {executable}")
def skip_unless_docker():
return skip_unless_executable("docker")
@@ -1,13 +1,13 @@
import pytest
from galaxy.tool_util.deps.mulled.mulled_search import (
conda_path,
CondaSearch,
get_package_hash,
GitHubSearch,
QuaySearch,
singularity_search,
)
from galaxy.util.unittest_utils import skip_unless_executable
from ..util import external_dependency_management
@@ -22,7 +22,7 @@ def test_quay_search():
@external_dependency_management
@pytest.mark.skipif(not conda_path, reason="requires conda on path")
@skip_unless_executable("conda")
def test_conda_search():
t = CondaSearch("bioconda")
search1 = t.get_json("asdfasdf")
@@ -1,14 +1,12 @@
import os
import pytest
from galaxy.tool_util.deps.mulled.get_tests import main_test_search
from galaxy.tool_util.deps.mulled.mulled_update_singularity_containers import (
docker_to_singularity,
get_list_from_file,
singularity_container_test,
)
from galaxy.util import which
from galaxy.util.unittest_utils import skip_unless_executable
from ..util import external_dependency_management
@@ -26,14 +24,14 @@ def test_get_list_from_file(tmp_path) -> None:
@external_dependency_management
@pytest.mark.skipif(not which("singularity"), reason="requires singularity but singularity not on PATH")
@skip_unless_executable("singularity")
def test_docker_to_singularity(tmp_path) -> None:
docker_to_singularity("abundancebin:1.0.1--0", "singularity", tmp_path, no_sudo=True)
assert tmp_path.joinpath("abundancebin:1.0.1--0").exists()
@external_dependency_management
@pytest.mark.skipif(not which("singularity"), reason="requires singularity but singularity not on PATH")
@skip_unless_executable("singularity")
def test_singularity_container_test(tmp_path) -> None:
containers = [
"pybigwig:0.3.22--py36h54a71a5_0", # test Python imports