Skip to content

Commit

Permalink
Drop __multicall__ from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Goodlet authored and goodboy committed Jun 3, 2020
1 parent b267687 commit d59403b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 42 deletions.
7 changes: 5 additions & 2 deletions testing/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
from pluggy import HookspecMarker, HookimplMarker
from pluggy.hooks import HookImpl
from pluggy.callers import _multicall, _legacymulticall
from pluggy.callers import _multicall

hookspec = HookspecMarker("example")
hookimpl = HookimplMarker("example")
Expand Down Expand Up @@ -38,7 +38,10 @@ def wrappers(request):
return [wrapper for i in range(request.param)]


@pytest.fixture(params=[_multicall, _legacymulticall], ids=lambda item: item.__name__)
@pytest.fixture(
params=[_multicall],
ids=lambda item: item.__name__
)
def callertype(request):
return request.param

Expand Down
41 changes: 1 addition & 40 deletions testing/test_multicall.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from pluggy import HookCallError, HookspecMarker, HookimplMarker
from pluggy.hooks import HookImpl
from pluggy.callers import _multicall, _legacymulticall
from pluggy.callers import _multicall


hookspec = HookspecMarker("example")
Expand All @@ -14,34 +14,9 @@ def MC(methods, kwargs, firstresult=False):
for method in methods:
f = HookImpl(None, "<temp>", method, method.example_impl)
hookfuncs.append(f)
if "__multicall__" in f.argnames:
caller = _legacymulticall
return caller(hookfuncs, kwargs, firstresult=firstresult)


def test_call_passing():
class P1(object):
@hookimpl
def m(self, __multicall__, x):
assert len(__multicall__.results) == 1
assert not __multicall__.hook_impls
return 17

class P2(object):
@hookimpl
def m(self, __multicall__, x):
assert __multicall__.results == []
assert __multicall__.hook_impls
return 23

p1 = P1()
p2 = P2()
reslist = MC([p1.m, p2.m], {"x": 23})
assert len(reslist) == 2
# ensure reversed order
assert reslist == [23, 17]


def test_keyword_args():
@hookimpl
def f(x):
Expand Down Expand Up @@ -74,20 +49,6 @@ def f(x):
MC([f], {})


def test_call_subexecute():
@hookimpl
def m(__multicall__):
subresult = __multicall__.execute()
return subresult + 1

@hookimpl
def n():
return 1

res = MC([n, m], {}, firstresult=True)
assert res == 2


def test_call_none_is_no_result():
@hookimpl
def m1():
Expand Down

0 comments on commit d59403b

Please sign in to comment.