Skip to content

Commit

Permalink
Merge pull request pytest-dev#343 from bluetech/test-no-hookspec
Browse files Browse the repository at this point in the history
Test calling a hook with no hookspec
  • Loading branch information
RonnyPfannschmidt authored Jan 12, 2022
2 parents 0e7970a + 4a0153e commit 4576615
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions testing/test_invocations.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,19 @@ def hello(self, arg):
pm.add_hookspecs(Api)
res = pm.hook.hello(arg=3)
assert res is None


def test_no_hookspec(pm: PluginManager) -> None:
"""A hook with hookimpls can still be called even if no hookspec
was registered for it (and call_pending wasn't called to check
against it).
"""

class Plugin:
@hookimpl
def hello(self, arg):
return "Plugin.hello"

pm.register(Plugin())

assert pm.hook.hello(arg=10, extra=20) == ["Plugin.hello"]

0 comments on commit 4576615

Please sign in to comment.