How to use the icontract.snapshot 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.snapshot(lambda lst: len(lst), name='len_lst')
            @icontract.post(lambda OLD, val, a_list: OLD.len_lst + 1 == len(a_list))
            def some_func(a_list: List[int], val: int) -> None:
                a_list.append(val)
github Parquery / icontract / tests / test_snapshot.py View on Github external
        @icontract.snapshot(lambda lst: len(lst), name="len_lst")
        @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_icontract.py View on Github external
        @icontract.snapshot(lambda lst: lst[:])
        @icontract.post(lambda OLD, val, lst: OLD.lst + [val] == 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.snapshot(lambda self: self.dels, name="dels")
            @icontract.ensure(lambda OLD, self: self.dels == OLD.dels + 1)
            def some_prop(self) -> None:
                # no self.dels increment
                return
github Parquery / icontract / tests / test_icontract.py View on Github external
                @icontract.snapshot(lambda self: self.gets, name="gets")
                @icontract.post(lambda OLD, self: self.gets == OLD.gets + 1)
                def some_prop(self) -> int:
                    return 0
github Parquery / icontract / tests / test_icontract.py View on Github external
            @icontract.snapshot(lambda self: self.dels, name="dels")
            @icontract.post(lambda OLD, self: self.sets == OLD.dels + 1)
            def some_prop(self) -> None:
                self.dels += 1
                return
github Parquery / icontract / tests / test_snapshot.py View on Github external
        @icontract.snapshot(lambda: z[:], name="z")
        @icontract.ensure(lambda OLD, val: OLD.z + [val] == z)
        def some_func(val: int) -> None:
            z.append(val)
github Parquery / icontract / tests / test_inheritance_snapshot.py View on Github external
            @icontract.snapshot(lambda self: self.dels, name="dels")
            @icontract.ensure(lambda OLD, self: self.dels == OLD.dels + 1)
            def some_prop(self) -> None:
                self.dels += 1
github Parquery / icontract / tests / test_icontract.py View on Github external
        @icontract.snapshot(lambda a: a[:])
        @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_snapshot.py View on Github external
        @icontract.snapshot(lambda lst: lst[:])
        @icontract.ensure(lambda OLD, val, lst: OLD.lst + [val] == lst)
        def some_func(lst: List[int], val: int) -> None:
            lst.append(val)