Skip to content

Commit 91b76cf

Browse files
committed
add test
1 parent 9e09cbe commit 91b76cf

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

tests/test_module_deeprank.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
"""Tests for the deeprank scoring module wrapper."""
22

3-
import tempfile
3+
import builtins
44
import shutil
5+
import tempfile
56
from pathlib import Path
67

78
import 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

1115
from . import golden_data as GOLDEN_DATA
1216
from .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
4767
def test_run(deeprank_wrapper):
4868
"""`run()` must return the score for the single input model."""

0 commit comments

Comments
 (0)