diff --git a/src/npe2/_plugin_manager.py b/src/npe2/_plugin_manager.py index 813a5ad0..d364cdeb 100644 --- a/src/npe2/_plugin_manager.py +++ b/src/npe2/_plugin_manager.py @@ -716,7 +716,7 @@ def _dispose(self): try: self._disposables.pop()() except Exception as e: - logger.warn(f"Error while disposing {self.plugin_key}; {e}") + logger.warning(f"Error while disposing {self.plugin_key}; {e}") def register_command(self, id: str, command: Optional[Callable] = None): """Associate a callable with a command id.""" diff --git a/tests/test_plugin_manager.py b/tests/test_plugin_manager.py index 41855f5a..8d1af5b9 100644 --- a/tests/test_plugin_manager.py +++ b/tests/test_plugin_manager.py @@ -224,8 +224,8 @@ def test_plugin_context_dispose(): mock.assert_called_once() -def test_plugin_context_dispose_error(): - """Test""" +def test_plugin_context_dispose_error(caplog): + """Test errors when executing dispose functions caught correctly.""" pm = PluginManager() mf = PluginManifest(name="test") pm.register(mf) @@ -234,6 +234,5 @@ def dummy_error(): raise ValueError("This is an error") pm.get_context("test").register_disposable(dummy_error) - msg = "Error while disposing test; This is an error" - with pytest.raises(ValueError, match=msg): - pm.deactivate("test") + pm.deactivate("test") + assert caplog.records[0].msg == "Error while disposing test; This is an error"