From 4e7d1833eb188ef6a7c5338a9167a8d78947ba82 Mon Sep 17 00:00:00 2001 From: Domagoj Fijan Date: Sun, 23 Jun 2024 21:27:55 -0400 Subject: [PATCH 1/4] resolve pymol autoskip --- tests/conftest.py | 2 +- tests/test_utils.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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_utils.py b/tests/test_utils.py index b9f6393..cb1bf7f 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -98,7 +98,7 @@ def test_read_results(water_results): assert waterH2[0] == [] -def test_visualise_pymol(): +def test_visualise_pymol(_pymol_skip): # Create a temporary file using with for writing and reading with tempfile.NamedTemporaryFile(mode="w+", suffix=".pse", delete=True) as f: tip_res, resO, resH1, resH2 = read_results( @@ -117,7 +117,7 @@ def test_visualise_pymol(): ) -def test_visualise_pymol2(): +def test_visualise_pymol2(_pymol_skip): # Create a temporary file using with for writing and reading with tempfile.NamedTemporaryFile(mode="w+", suffix=".pdb", delete=True) as f: visualise_pymol( @@ -141,7 +141,7 @@ def test_visualise_pymol2(): ("tests/data/merged_new_clustering_results_noH.dat", "tests/data/aligned.pdb"), ], ) -def test_visualise_pymol_with_align_protein(output_file, align_file): +def test_visualise_pymol_with_align_protein(output_file, align_file, _pymol_skip): visualise_pymol( *read_results(output_file), aligned_protein=align_file, From e1752abf81c5735ee509d92abd0a4fbe3e80aa02 Mon Sep 17 00:00:00 2001 From: Domagoj Fijan Date: Sun, 23 Jun 2024 21:28:01 -0400 Subject: [PATCH 2/4] update precommit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 235df9a141fc5a12a4d84c48eda090aece36ed2f Mon Sep 17 00:00:00 2001 From: Domagoj Fijan Date: Sun, 23 Jun 2024 21:29:33 -0400 Subject: [PATCH 3/4] lint --- tests/test_hydrogen_orientation.py | 3 +-- tests/test_utils.py | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) 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 cb1bf7f..90d772e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -98,7 +98,8 @@ def test_read_results(water_results): assert waterH2[0] == [] -def test_visualise_pymol(_pymol_skip): +@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: tip_res, resO, resH1, resH2 = read_results( @@ -117,7 +118,8 @@ def test_visualise_pymol(_pymol_skip): ) -def test_visualise_pymol2(_pymol_skip): +@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: visualise_pymol( @@ -133,6 +135,7 @@ def test_visualise_pymol2(_pymol_skip): # Visualise pymol tests +@pytest.mark.usefixtures("_pymol_skip") @pytest.mark.parametrize( ("output_file", "align_file"), [ @@ -141,7 +144,7 @@ def test_visualise_pymol2(_pymol_skip): ("tests/data/merged_new_clustering_results_noH.dat", "tests/data/aligned.pdb"), ], ) -def test_visualise_pymol_with_align_protein(output_file, align_file, _pymol_skip): +def test_visualise_pymol_with_align_protein(output_file, align_file): visualise_pymol( *read_results(output_file), aligned_protein=align_file, From c3c508e5798272c75b2d275e97458ee3543f58f7 Mon Sep 17 00:00:00 2001 From: Domagoj Fijan Date: Sun, 23 Jun 2024 21:45:17 -0400 Subject: [PATCH 4/4] update CI --- .github/workflows/CI.yaml | 11 ++++++----- requirements/requirements-test.txt | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) 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/requirements/requirements-test.txt b/requirements/requirements-test.txt index 2725af4..409c04f 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.4.2 +pytest==8.2.2