diff --git a/envisage/plugin_manager.py b/envisage/plugin_manager.py index 74beb75bb..d7c1e9cf9 100644 --- a/envisage/plugin_manager.py +++ b/envisage/plugin_manager.py @@ -12,6 +12,7 @@ from fnmatch import fnmatch import logging +import warnings from traits.api import Event, HasTraits, Instance, List, observe, provides, Str @@ -82,6 +83,14 @@ def __init__(self, plugins=None, **traits): plugins use 'for plugin in plugin_manager'. """ + if "include" in traits or "exclude" in traits: + warnings.warn( + "The 'include' and 'exclude' traits to PluginManager " + "are deprecated, and will be removed in a future version " + "of Envisage", + DeprecationWarning, + stacklevel=2, + ) super().__init__(**traits) diff --git a/envisage/tests/test_plugin_manager.py b/envisage/tests/test_plugin_manager.py index e3f2ed280..e3615bb60 100644 --- a/envisage/tests/test_plugin_manager.py +++ b/envisage/tests/test_plugin_manager.py @@ -143,14 +143,15 @@ def test_only_include_plugins_whose_ids_are_in_the_include_list(self): # plugins Ids. include = ["foo", "bar"] - plugin_manager = PluginManager( - include=include, - plugins=[ - SimplePlugin(id="foo"), - SimplePlugin(id="bar"), - SimplePlugin(id="baz"), - ], - ) + with self.assertWarns(DeprecationWarning): + plugin_manager = PluginManager( + include=include, + plugins=[ + SimplePlugin(id="foo"), + SimplePlugin(id="bar"), + SimplePlugin(id="baz"), + ], + ) # The Ids of the plugins that we expect the plugin manager to find. expected = ["foo", "bar"] @@ -167,14 +168,15 @@ def test_only_include_plugins_matching_a_wildcard_in_the_include_list( # plugins Ids. include = ["b*"] - plugin_manager = PluginManager( - include=include, - plugins=[ - SimplePlugin(id="foo"), - SimplePlugin(id="bar"), - SimplePlugin(id="baz"), - ], - ) + with self.assertWarns(DeprecationWarning): + plugin_manager = PluginManager( + include=include, + plugins=[ + SimplePlugin(id="foo"), + SimplePlugin(id="bar"), + SimplePlugin(id="baz"), + ], + ) # The Ids of the plugins that we expect the plugin manager to find. expected = ["bar", "baz"] @@ -189,14 +191,15 @@ def test_ignore_plugins_whose_ids_are_in_the_exclude_list(self): # plugins Ids. exclude = ["foo", "baz"] - plugin_manager = PluginManager( - exclude=exclude, - plugins=[ - SimplePlugin(id="foo"), - SimplePlugin(id="bar"), - SimplePlugin(id="baz"), - ], - ) + with self.assertWarns(DeprecationWarning): + plugin_manager = PluginManager( + exclude=exclude, + plugins=[ + SimplePlugin(id="foo"), + SimplePlugin(id="bar"), + SimplePlugin(id="baz"), + ], + ) # The Ids of the plugins that we expect the plugin manager to find. expected = ["bar"] @@ -211,14 +214,15 @@ def test_ignore_plugins_matching_a_wildcard_in_the_exclude_list(self): # plugins Ids. exclude = ["b*"] - plugin_manager = PluginManager( - exclude=exclude, - plugins=[ - SimplePlugin(id="foo"), - SimplePlugin(id="bar"), - SimplePlugin(id="baz"), - ], - ) + with self.assertWarns(DeprecationWarning): + plugin_manager = PluginManager( + exclude=exclude, + plugins=[ + SimplePlugin(id="foo"), + SimplePlugin(id="bar"), + SimplePlugin(id="baz"), + ], + ) # The Ids of the plugins that we expect the plugin manager to find. expected = ["foo"]