Skip to content

Commit

Permalink
Test both AttributeError and ImportError in is_jupyter
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Peter Krone committed Dec 19, 2024
1 parent 4203232 commit a8ad0dc
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/test_without_pyqt6.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@
from iminuit.cost import LeastSquares
import pytest

pytest.importorskip("matplotlib")

def test_interactive():
pytest.importorskip("matplotlib")

def test_pyqt6_interactive_with_ipython():
pytest.importorskip("IPython")
import iminuit

cost = LeastSquares([1.1, 2.2], [3.3, 4.4], 1, lambda x, a: a * x)

with hide_modules("PyQt6", reload="iminuit.qtwidget"):
with pytest.raises(ModuleNotFoundError, match="Please install PyQt6"):
iminuit.Minuit(cost, 1).interactive()


def test_pyqt6_interactive_without_ipython():
import iminuit

cost = LeastSquares([1.1, 2.2], [3.3, 4.4], 1, lambda x, a: a * x)

with hide_modules("PyQt6", "IPython", reload="iminuit.qtwidget"):
with pytest.raises(ModuleNotFoundError, match="Please install PyQt6"):
iminuit.Minuit(cost, 1).interactive()

0 comments on commit a8ad0dc

Please sign in to comment.