diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 75f79f6..be028a1 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -20,7 +20,6 @@ jobs: uses: conda-incubator/setup-miniconda@v3 with: python-version: ${{ matrix.python-version }} - environment-file: .github/workflows/envs/environment.yml channels: conda-forge activate-environment: test show-channel-urls: true @@ -29,10 +28,13 @@ jobs: - name: Check and Conditionally Install PyMOL shell: bash -l {0} run: | + PYMOL_VER=3.0.0 PYTHON_VER=${{ matrix.python-version }} PYTHON_VER=${PYTHON_VER//./} # Remove the dot from the Python version - if mamba search -c conda-forge pymol-open-source=3.0.0 | grep -q "py${PYTHON_VER}"; then - mamba install -c conda-forge pymol-open-source=3.0.0 + if mamba search -c conda-forge pymol-open-source==${PYMOL_VER} | grep -q "py${PYTHON_VER}"; then + mamba install -c conda-forge pymol-open-source==${PYMOL_VER} --file requirements/requirements-test.txt + else + mamba install -c conda-forge --file requirements/requirements-test.txt fi - name: Install package shell: bash -l {0} @@ -42,5 +44,4 @@ jobs: shell: bash -l {0} run: | which python - python -m pip install pytest - pytest + python -m pytest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 64394a8..f012d4e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: - id: requirements-txt-fixer - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.2.2 + rev: v0.4.10 hooks: # Run the linter. - id: ruff diff --git a/requirements/requirements-test.txt b/requirements/requirements-test.txt index d9192f2..ca94c95 100644 --- a/requirements/requirements-test.txt +++ b/requirements/requirements-test.txt @@ -2,3 +2,4 @@ matplotlib==3.8.4 nglview==3.1.2 numpy==1.26.4 scikit-learn==1.5.0 +pytest==8.2.2 diff --git a/tests/conftest.py b/tests/conftest.py index cac54a3..a06096f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -37,7 +37,7 @@ def water_data(request): return np.loadtxt(request.param), request.param.split("/")[-1].split(".")[0] -@pytest.fixture(autouse=True) +@pytest.fixture() def _pymol_skip(): pytest.importorskip("pymol") diff --git a/tests/test_hydrogen_orientation.py b/tests/test_hydrogen_orientation.py index b8eff16..b89dcda 100644 --- a/tests/test_hydrogen_orientation.py +++ b/tests/test_hydrogen_orientation.py @@ -1,5 +1,4 @@ -"""Unit and regression test for the ConservedWaterSearch package. -""" +"""Unit and regression test for the ConservedWaterSearch package.""" # Import package, test suite, and other packages as needed import numpy as np diff --git a/tests/test_utils.py b/tests/test_utils.py index b9f6393..90d772e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -98,6 +98,7 @@ def test_read_results(water_results): assert waterH2[0] == [] +@pytest.mark.usefixtures("_pymol_skip") def test_visualise_pymol(): # Create a temporary file using with for writing and reading with tempfile.NamedTemporaryFile(mode="w+", suffix=".pse", delete=True) as f: @@ -117,6 +118,7 @@ def test_visualise_pymol(): ) +@pytest.mark.usefixtures("_pymol_skip") def test_visualise_pymol2(): # Create a temporary file using with for writing and reading with tempfile.NamedTemporaryFile(mode="w+", suffix=".pdb", delete=True) as f: @@ -133,6 +135,7 @@ def test_visualise_pymol2(): # Visualise pymol tests +@pytest.mark.usefixtures("_pymol_skip") @pytest.mark.parametrize( ("output_file", "align_file"), [