From 53d1cfc3a1f002a25eb3635946b6415a6c810951 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 1 Nov 2010 09:20:58 +0100 Subject: [PATCH] allow unregistration by name --- pytest/__init__.py | 2 +- pytest/_core.py | 6 ++++-- setup.py | 2 +- testing/test_pluginmanager.py | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pytest/__init__.py b/pytest/__init__.py index 43b1b505e..f9d9caf1e 100644 --- a/pytest/__init__.py +++ b/pytest/__init__.py @@ -5,7 +5,7 @@ see http://pytest.org for documentation and details (c) Holger Krekel and others, 2004-2010 """ -__version__ = '2.0.0.dev16' +__version__ = '2.0.0.dev17' __all__ = ['config', 'cmdline'] diff --git a/pytest/_core.py b/pytest/_core.py index 5b7141a64..0e9d7731b 100644 --- a/pytest/_core.py +++ b/pytest/_core.py @@ -47,9 +47,11 @@ class PluginManager(object): self._plugins.insert(0, plugin) return True - def unregister(self, plugin): - self.hook.pytest_plugin_unregistered(plugin=plugin) + def unregister(self, plugin=None, name=None): + if plugin is None: + plugin = self.getplugin(name=name) self._plugins.remove(plugin) + self.hook.pytest_plugin_unregistered(plugin=plugin) for name, value in list(self._name2plugin.items()): if value == plugin: del self._name2plugin[name] diff --git a/setup.py b/setup.py index 92a616b2f..bd8e05669 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.0.0.dev16', + version='2.0.0.dev17', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 1200b592e..0bd906faa 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -164,7 +164,7 @@ class TestBootstrapping: assert pp.getplugin('hello') == a2 pp.unregister(a1) assert not pp.isregistered(a1) - pp.unregister(a2) + pp.unregister(name="hello") assert not pp.isregistered(a2) def test_pm_ordering(self):