allow unregistration by name

This commit is contained in:
holger krekel 2010-11-01 09:20:58 +01:00
parent 32ac7a7c6e
commit 53d1cfc3a1
4 changed files with 7 additions and 5 deletions

View File

@ -5,7 +5,7 @@ see http://pytest.org for documentation and details
(c) Holger Krekel and others, 2004-2010 (c) Holger Krekel and others, 2004-2010
""" """
__version__ = '2.0.0.dev16' __version__ = '2.0.0.dev17'
__all__ = ['config', 'cmdline'] __all__ = ['config', 'cmdline']

View File

@ -47,9 +47,11 @@ class PluginManager(object):
self._plugins.insert(0, plugin) self._plugins.insert(0, plugin)
return True return True
def unregister(self, plugin): def unregister(self, plugin=None, name=None):
self.hook.pytest_plugin_unregistered(plugin=plugin) if plugin is None:
plugin = self.getplugin(name=name)
self._plugins.remove(plugin) self._plugins.remove(plugin)
self.hook.pytest_plugin_unregistered(plugin=plugin)
for name, value in list(self._name2plugin.items()): for name, value in list(self._name2plugin.items()):
if value == plugin: if value == plugin:
del self._name2plugin[name] del self._name2plugin[name]

View File

@ -22,7 +22,7 @@ def main():
name='pytest', name='pytest',
description='py.test: simple powerful testing with Python', description='py.test: simple powerful testing with Python',
long_description = long_description, long_description = long_description,
version='2.0.0.dev16', version='2.0.0.dev17',
url='http://pytest.org', url='http://pytest.org',
license='MIT license', license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],

View File

@ -164,7 +164,7 @@ class TestBootstrapping:
assert pp.getplugin('hello') == a2 assert pp.getplugin('hello') == a2
pp.unregister(a1) pp.unregister(a1)
assert not pp.isregistered(a1) assert not pp.isregistered(a1)
pp.unregister(a2) pp.unregister(name="hello")
assert not pp.isregistered(a2) assert not pp.isregistered(a2)
def test_pm_ordering(self): def test_pm_ordering(self):