Skip to content

Commit

Permalink
PluginManager.get_plugins no longer returns None for blocked plugins (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Feb 19, 2024
1 parent 22485d1 commit 4326ced
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/481.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``PluginManager.get_plugins()`` no longer returns ``None`` for blocked plugins.
2 changes: 1 addition & 1 deletion src/pluggy/_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def parse_hookspec_opts(

def get_plugins(self) -> set[Any]:
"""Return a set of all registered plugin objects."""
return set(self._name2plugin.values())
return {x for x in self._name2plugin.values() if x is not None}

def is_registered(self, plugin: _Plugin) -> bool:
"""Return whether the plugin is already registered."""
Expand Down
4 changes: 4 additions & 0 deletions testing/test_pluginmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,19 @@ class A:
assert name is not None
assert pm.is_registered(a1)
assert not pm.is_blocked(name)
assert pm.get_plugins() == {a1}

pm.set_blocked(name)
assert pm.is_blocked(name)
assert not pm.is_registered(a1)
assert pm.get_plugins() == set()

pm.set_blocked("somename")
assert pm.is_blocked("somename")
assert not pm.register(A(), "somename")
pm.unregister(name="somename")
assert pm.is_blocked("somename")
assert pm.get_plugins() == set()

# Unblock.
assert not pm.unblock("someothername")
Expand Down

0 comments on commit 4326ced

Please sign in to comment.