$ cd morepath
$ ./bin/py.test morepath src/reg/reg
____________________________________________________________________________ test_no_implicit _____________________________________________________________________________
def test_no_implicit():
@dispatch('obj')
def target(obj):
pass
alpha = Alpha()
with pytest.raises(NoImplicitLookupError):
> target.component(alpha)
src/reg/reg/tests/test_dispatch.py:549:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/reg/reg/dispatch.py:58: in component
return get_lookup(kw).component(self.wrapped_func, *args, **kw)
src/reg/reg/registry.py:424: in component
key = self.key_lookup.predicate_key(callable, *args, **kw)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <morepath.cachingreg.RegRegistry object at 0x10fd38510>, callable = <function target at 0x10fe3cf50>
args = (<reg.tests.test_dispatch.Alpha object at 0x10fda52d0>,), kw = {}, r = None
def predicate_key(self, callable, *args, **kw):
"""Construct predicate_key for function arguments.
For a callable and its function arguments, construct the
appropriate predicate_key. This is used by the dispatch
mechanism to dispatch to the right function.
If the predicate_key cannot be constructed from args and kw,
this raises a :exc:`KeyExtractorError`.
:param callable: the callable for which to extract the predicate_key
:param args: the varargs given to the callable.
:param kw: the keyword arguments given to the callable.
:returns: an immutable predicate_key based on the predicates
the callable was configured with.
"""
r = self.predicate_registries.get(callable)
if r is None:
> raise KeyExtractorError()
E KeyExtractorError
src/reg/reg/registry.py:223: KeyExtractorError
1 failed, 595 passed in 1.35 seconds