Skip to content

Commit

Permalink
Handle firstresult hooks that return None
Browse files Browse the repository at this point in the history
Only return the first result when at least one result has been returned
by underlying hook implementations.

Fixes #68
  • Loading branch information
Tyler Goodlet committed Aug 29, 2017
1 parent 5ab312c commit f1a2270
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pluggy/callers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def execute(self):
pass

if firstresult:
return outcome.get_result()[0]
result = outcome.get_result()
return result[0] if result else None

return outcome.get_result()

Expand Down
4 changes: 2 additions & 2 deletions testing/test_hookrelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def hello(self, arg):

pm.register(Plugin1())
res = pm.hook.hello(arg=3)
assert res == None
assert res is None


def test_firstresult_no_plugin(pm):
Expand All @@ -126,4 +126,4 @@ def hello(self, arg):

pm.add_hookspecs(Api)
res = pm.hook.hello(arg=3)
assert res == None
assert res is None

0 comments on commit f1a2270

Please sign in to comment.