Skip to content

Commit 4576615

Browse files
Merge pull request #343 from bluetech/test-no-hookspec
Test calling a hook with no hookspec
2 parents 0e7970a + 4a0153e commit 4576615

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

testing/test_invocations.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,19 @@ def hello(self, arg):
213213
pm.add_hookspecs(Api)
214214
res = pm.hook.hello(arg=3)
215215
assert res is None
216+
217+
218+
def test_no_hookspec(pm: PluginManager) -> None:
219+
"""A hook with hookimpls can still be called even if no hookspec
220+
was registered for it (and call_pending wasn't called to check
221+
against it).
222+
"""
223+
224+
class Plugin:
225+
@hookimpl
226+
def hello(self, arg):
227+
return "Plugin.hello"
228+
229+
pm.register(Plugin())
230+
231+
assert pm.hook.hello(arg=10, extra=20) == ["Plugin.hello"]

0 commit comments

Comments
 (0)