File tree Expand file tree Collapse file tree
src/haddock/modules/scoring/deeprank Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010
1111
1212def deeprank_is_available () -> bool :
13- """Check whether the `deeprank_gnn` package is importable."""
14- import deeprank_gnn # type: ignore # noqa: F401
13+ """Check whether deeprank-gnn-esm's requirements are met."""
14+ try :
15+ import sqlite3 # noqa: F401
16+ except ImportError as err :
17+ raise ImportError (
18+ "The `deeprank` module requires a python interpreter built with "
19+ "sqlite3 support, which is missing from your current "
20+ "environment."
21+ ) from err
22+
23+ try :
24+ import deeprank_gnn # type: ignore # noqa: F401
25+ except ImportError as err :
26+ raise ImportError (
27+ "The `deeprank` module requires the `deeprank_gnn` package, "
28+ "which is not installed in your current environment."
29+ ) from err
1530
1631 return True
1732
Original file line number Diff line number Diff line change 11"""Tests for the deeprank scoring module wrapper."""
22
3- import tempfile
3+ import builtins
44import shutil
5+ import tempfile
56from pathlib import Path
67
78import pytest
89
9- from haddock .modules .scoring .deeprank .deeprank import DeeprankWrapper
10+ from haddock .modules .scoring .deeprank .deeprank import (
11+ DeeprankWrapper ,
12+ deeprank_is_available ,
13+ )
1014
1115from . import golden_data as GOLDEN_DATA
1216from .conftest import has_deeprank
@@ -43,6 +47,22 @@ def deeprank_wrapper_ensemble():
4347 )
4448
4549
50+ def test_deeprank_is_available_requires_sqlite3 (monkeypatch ):
51+ """Must raise a clear error when the interpreter lacks sqlite3 support."""
52+ real_import = builtins .__import__
53+
54+ # mock not being able to find `sqlite3`
55+ def fake_import (name , * args , ** kwargs ):
56+ if name == "sqlite3" :
57+ raise ImportError ("No module named '_sqlite3'" )
58+ return real_import (name , * args , ** kwargs )
59+
60+ monkeypatch .setattr (builtins , "__import__" , fake_import )
61+
62+ with pytest .raises (ImportError , match = "sqlite3" ):
63+ deeprank_is_available ()
64+
65+
4666@has_deeprank
4767def test_run (deeprank_wrapper ):
4868 """`run()` must return the score for the single input model."""
You can’t perform that action at this time.
0 commit comments