Skip to content

Commit

Permalink
Add a test demonstrating the opt in nature of args
Browse files Browse the repository at this point in the history
Args are always opt in for hookimpls regardless of whether the spec or
call defines more then the impl accepts.

Relates to pytest-dev#170
  • Loading branch information
Tyler Goodlet committed Aug 8, 2018
1 parent 6587ed0 commit 10bd3bd
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions testing/test_invocations.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@ 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, old_arg, new_arg, common_arg):
"api hook 1"

class LegacyPlugin(object):
@hookimpl
def hello(self, old_arg, common_arg):
return old_arg + common_arg

class Plugin(object):
@hookimpl
def hello(self, new_arg, common_arg):
return new_arg + common_arg

pm.add_hookspecs(Api)
pm.register(LegacyPlugin())
pm.register(Plugin())

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


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

0 comments on commit 10bd3bd

Please sign in to comment.