How to use the icontract.ensure function in icontract

To help you get started, we’ve selected a few icontract examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Parquery / icontract / tests / test_represent.py View on Github external
        @icontract.ensure(lambda result: all(single_res[1].is_absolute() for single_res in result))
        def some_func() -> List[Tuple[pathlib.Path, pathlib.Path]]:
            return [(pathlib.Path("/home/file1"), pathlib.Path("home/file2"))]
github Parquery / icontract / tests / test_inheritance_postcondition.py View on Github external
            @icontract.ensure(lambda result: result < 100)
            def func(self) -> int:
                return 1000
github Parquery / icontract / tests / test_postcondition.py View on Github external
            @icontract.ensure(lambda self: self.some_prop > 0)
            def some_prop(self) -> None:
                pass
github Parquery / icontract / tests / test_invariant.py View on Github external
            @icontract.ensure(lambda result: result > 0)
            def some_method(self) -> int:
                self.x = -1
                return 10
github Parquery / icontract / tests / test_snapshot.py View on Github external
        @icontract.ensure(lambda OLD, val, lst: OLD.len_lst + 1 == len(lst))
        def some_func(lst: List[int], val: int) -> None:
            lst.append(val)
            lst.append(1984)
github Parquery / icontract / tests / test_inheritance_snapshot.py View on Github external
            @icontract.ensure(lambda OLD, self, val: OLD.lst + [val] == self.lst)
            def some_func(self, val: int) -> None:
                self.lst.append(val)
                self.lst.append(1984)
github Parquery / icontract / tests / test_postcondition.py View on Github external
        @icontract.ensure(lambda result, x: result > x, "expected summation")
        def some_func(x: int, y: int = 5) -> int:
            return x - y
github Parquery / icontract / tests / test_inheritance_postcondition.py View on Github external
            @icontract.ensure(lambda result: result % 3 == 0)
            def func(self) -> int:
                return 2
github Parquery / icontract / tests / test_snapshot.py View on Github external
        @icontract.ensure(lambda OLD, val, lst: OLD.len_lst + 1 == len(lst))
        def some_func(lst: List[int], val: int) -> None:
            lst.append(val)