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 committed May 18, 2018
1 parent 5ea8116 commit 3c22562
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 60 deletions.
4 changes: 2 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 @@ -45,7 +45,7 @@ def wrappers(request):


@pytest.fixture(
params=[_multicall, _legacymulticall],
params=[_multicall],
ids=lambda item: item.__name__
)
def callertype(request):
Expand Down
50 changes: 1 addition & 49 deletions testing/test_multicall.py
Original file line number Diff line number Diff line change
@@ -1,56 +1,22 @@
import pytest
from pluggy import HookCallError, HookspecMarker, HookimplMarker
from pluggy.hooks import HookImpl
from pluggy.callers import _multicall, _legacymulticall, _LegacyMultiCall
from pluggy.callers import _multicall


hookspec = HookspecMarker("example")
hookimpl = HookimplMarker("example")


def test_uses_copy_of_methods():
out = [lambda: 42]
mc = _LegacyMultiCall(out, {})
repr(mc)
out[:] = []
res = mc.execute()
return res == 42


def MC(methods, kwargs, firstresult=False):
caller = _multicall
hookfuncs = []
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 @@ -81,20 +47,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
9 changes: 0 additions & 9 deletions testing/test_pluginmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,6 @@ class PluginNo(object):
assert out == [10]


def test_multicall_deprecated(pm):
class P1(object):
@hookimpl
def m(self, __multicall__, x):
pass

pytest.deprecated_call(pm.register, P1())


def test_add_hookspecs_nohooks(pm):
with pytest.raises(ValueError):
pm.add_hookspecs(10)
Expand Down

0 comments on commit 3c22562

Please sign in to comment.