Skip to content

Commit

Permalink
fix issue pytest-dev#17 by considering only routines as hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt committed Nov 11, 2016
1 parent 6aaaf0e commit df1f335
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
- fix bug where callbacks for historic hooks would not be called for
already registered plugins. Thanks Simon Gmizelj for the PR
and holger krekel for further fixes.
- fix #17 by considering only actual functions for hooks
this removes the ability to register arbitrary callable objects
which at first glance is a reasonable simplification,
thanks RonnyPfannschmidt for report and pr.

0.4.0
-----
Expand Down
2 changes: 2 additions & 0 deletions pluggy.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ def register(self, plugin, name=None):

def parse_hookimpl_opts(self, plugin, name):
method = getattr(plugin, name)
if not inspect.isroutine(method):
return
try:
res = getattr(method, self.project_name + "_impl", None)
except Exception:
Expand Down
5 changes: 0 additions & 5 deletions testing/test_pluggy.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,17 +660,12 @@ def test_prefix_hookimpl_dontmatch_module(self):
pm = PluginManager(hookspec.project_name, "hello_")

class BadPlugin:
def hello_fine(self):
pass
hello_fine.optionalhook = True

hello_module = __import__('email')

pm.register(BadPlugin())
pm.check_pending()



def test_parse_hookimpl_override():
class MyPluginManager(PluginManager):
def parse_hookimpl_opts(self, module_or_class, name):
Expand Down

0 comments on commit df1f335

Please sign in to comment.