Exemple #1
0
def _curry_rhs(rhs) -> t.Callable:
    """
    Late evaluation of a RHS of an operation.

    :param rhs: Right-hand side of an operation.
    :returns: If RHS is a Var instance, it will return a method for
     an extraction of a value when the value is evaluated. Otherwise, it
     returns a constant function of RHS.
    """
    if isinstance(rhs, Var):
        return resolve_path(rhs._path)
    return lambda value: rhs
Exemple #2
0
def _curry_rhs(rhs) -> t.Callable:
    """
    Late evaluation of a RHS of an operation.

    :param rhs: Right-hand side of an operation.
    :returns: If RHS is a Var instance, it will return a method for
     an extraction of a value when the value is evaluated. Otherwise, it
     returns a constant function of RHS.
    """
    if isinstance(rhs, Var):
        return resolve_path(rhs._path)
    return lambda value: rhs
Exemple #3
0
def test_resolve_path_object_negative(example_object, path):
    resolve_path_curried = resolve_path(path)
    with pytest.raises(PathNotFoundError):
        resolve_path_curried(example_object)
Exemple #4
0
def test_resolve_path_object_positive(example_object, path, expected):
    resolve_path_curried = resolve_path(path)
    assert resolve_path_curried(example_object) == expected