1 import importlib 2 import pytest 3 from IPython.external.qt_loaders import ID 4 5 6 def test_import_denier(): 7 ID.forbid("ipython_denied_module") 8 with pytest.raises(ImportError, match="disabled by IPython"): 9 import ipython_denied_module 10 with pytest.raises(ImportError, match="disabled by IPython"): 11 importlib.import_module("ipython_denied_module") 12