

def test_convert_is_robust_to_failures():
    foo = NetworkDispatcher('foo')

    def badfunc(*args, **kwargs):
        raise NotImplementedError()

    class A(object):
        pass

    class B(object):
        pass

    class C(object):
        pass
    discover.register((A, B, C))((lambda x: 'int'))
    foo.register(B, A, cost=1.0)((lambda x, **kwargs: 1))
    x.register(C, B, cost=1.0)(badfunc)
    foo.register(C, A, cost=10.0)((lambda x, **kwargs: 2))
    with warnings.catch_warnings(record=True) as ws:
        warnings.simplefilter('always')
        assert (foo(C, A()) == 2)
    assert (len(ws) == 1)
    w = ws[0].message
    assert isinstance(w, FailedConversionWarning)
    assert ('B -> C' in str(w))

dataset/ETHPy150Open blaze/odo/odo/tests/test_core.py test_convert_is_robust_to_failures/VarMisuse@116/136 `foo`->`x`