Exemplo n.º 1
0
    def _build_predicate(self, test: t.Callable, operation: Operation,
                         args: t.Iterable) -> Predicate:
        """
        Generate a Predicate object based on a test function.

        :param test: The test the Predicate executes.
        :param operation: An `Operation` instance for the Predicate.
        :return: A `Predicate` object
        """
        if not self._path:
            raise ValueError('Var has no path')
        return Predicate(check_path(test, self._path), operation, args,
                         self._name)
Exemplo n.º 2
0
    def _build_predicate(
            self,
            test: t.Callable,
            operation: Operation,
            args: t.Iterable
            ) -> Predicate:
        """
        Generate a Predicate object based on a test function.

        :param test: The test the Predicate executes.
        :param operation: An `Operation` instance for the Predicate.
        :return: A `Predicate` object
        """
        if not self._path:
            raise ValueError('Var has no path')
        return Predicate(
            check_path(test, self._path),
            operation,
            args,
            self._name
        )
Exemplo n.º 3
0
def test_test_path_dict(example_dict, path, expected):
    # this is the same as `bool`, but let's be explicit about intentions
    test = lambda lhs, value: bool(lhs)  # noqa: E731
    resolve_path_curried = check_path(test, path)
    assert resolve_path_curried(example_dict) == expected