How to use the icontract.post 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_icontract.py View on Github external
            @icontract.post(lambda self: self.x >= 0)
            def __init__(self, x: int) -> None:
                self.x = x
github Parquery / icontract / tests / test_icontract.py View on Github external
        @icontract.post(lambda x, result: x > result, enabled=False)
        def some_func(x: int) -> int:
            return 123
github Parquery / icontract / tests / test_icontract.py View on Github external
        @icontract.post(lambda OLD, a: a == OLD.a)
        def some_function(a: List[int], OLD: int) -> None:  # pylint: disable=unused-variable
            pass
github Parquery / icontract / tests / test_icontract.py View on Github external
            @icontract.post(lambda result: result > 0)
            def some_method(self) -> int:
                self.x = 10
                return -1
github Parquery / icontract / tests / test_icontract.py View on Github external
        @icontract.post(lambda OLD, val, lst: OLD.lst + [val] == lst)
        def some_func(lst: List[int], val: int) -> None:
            lst.append(val)
github Parquery / icontract / tests / test_icontract.py View on Github external
        @icontract.post(lambda result, x: len(result) > x, a_repr=a_repr)
        def some_func(x: int) -> List[int]:
            return list(range(x))
github Parquery / icontract / tests / test_icontract.py View on Github external
        @icontract.post(lambda result: result > 0, error=lambda: ValueError("result must be positive"))
        def some_func(x: int) -> int:
            return x
github Parquery / icontract / tests / test_icontract.py View on Github external
            @icontract.post(lambda self: self.x < 0)
            def __init__(self, x: int) -> None:
                self.x = x
github Parquery / icontract / tests / test_icontract.py View on Github external
                @icontract.post(lambda OLD, self: self.sets == OLD.sets + 1)
                def some_prop(self, value: int) -> None:
                    return
github Parquery / icontract / tests / test_icontract.py View on Github external
        @icontract.post(
            lambda result, x: result > x, repr_args=lambda result, x: "result was {:05}, x was {:05}".format(result, x))
        def some_func(x: int, y: int = 5) -> int:
            return x - y