Skip to content

Commit 8c50bb0

Browse files
committed
Fix tests
1 parent 9604eaa commit 8c50bb0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

python/evalica/test_alpha.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import sys
4+
import unittest.mock
35
from functools import partial
46
from typing import TYPE_CHECKING, Literal
57

@@ -371,3 +373,18 @@ def custom_abs_diff(left: float, right: float) -> float:
371373
assert result_pyo3.alpha == pytest.approx(result_naive.alpha)
372374
assert result_pyo3.observed == pytest.approx(result_naive.observed)
373375
assert result_pyo3.expected == pytest.approx(result_naive.expected)
376+
377+
378+
def test_alpha_solver_error() -> None:
379+
with unittest.mock.patch.dict(sys.modules, {"evalica._brzo": None}):
380+
sys.modules.pop("evalica", None)
381+
382+
with pytest.warns():
383+
import evalica # noqa: PLC0415
384+
385+
assert not evalica.PYO3_AVAILABLE
386+
387+
data = pd.DataFrame([[1, 2], [2, 3]])
388+
389+
with pytest.raises(evalica.SolverError, match="The 'pyo3' solver is not available"):
390+
evalica.alpha(data, solver="pyo3")

0 commit comments

Comments
 (0)