Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test demonstrating the opt in nature of args #172

Merged
merged 1 commit into from
Aug 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/172.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a test exemplifying the opt-in nature of spec defined args.
28 changes: 28 additions & 0 deletions testing/test_invocations.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,34 @@ def hello(self, arg):
assert comprehensible in str(exc.value)


def test_opt_in_args(pm):
"""Verfiy that two hookimpls with mutex args can serve
under the same spec.
"""

class Api(object):
@hookspec
def hello(self, arg1, arg2, common_arg):
"api hook 1"

class Plugin1(object):
@hookimpl
def hello(self, arg1, common_arg):
return arg1 + common_arg

class Plugin2(object):
@hookimpl
def hello(self, arg2, common_arg):
return arg2 + common_arg

pm.add_hookspecs(Api)
pm.register(Plugin1())
pm.register(Plugin2())

results = pm.hook.hello(arg1=1, arg2=2, common_arg=0)
assert results == [2, 1]


def test_call_order(pm):
class Api(object):
@hookspec
Expand Down