How to use the deal.post function in deal

To help you get started, we’ve selected a few deal 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 life4 / deal / tests / test_decorators / test_post.py View on Github external
    @deal.post(lambda x: x <= 8)
    def double(x):
        yield x
        yield x * 2
        yield x * 4
github life4 / deal / tests / test_decorators / test_post.py View on Github external
    @deal.post(lambda x: x > 0)
    async def func(x):
        return -x
github life4 / deal / tests.py View on Github external
def test_main(self):
        func = deal.post(lambda x: x > 0)(lambda x: -x)
        with self.subTest(text='good'):
            self.assertEqual(func(-4), 4)
        with self.subTest(text='error'):
            with pytest.raises(deal.PostContractError):
                func(4)
github life4 / deal / tests / test_aliases.py View on Github external
    @deal.post(lambda x: x > 0)
    @deal.ensure(lambda *args, **kwargs: True)
    @deal.raises(ValueError)
    @deal.offline()
    @deal.offline
    @deal.safe
    @deal.safe()
    @deal.silent
    @deal.silent()
    @deal.pure
    @deal.chain(deal.safe, deal.silent)
    def func(x: int) -> int:
        """docs were before docker
        """
        return x
github life4 / deal / tests / test_decorators / test_post.py View on Github external
def test_return_value_fulfils_contract():
    func = deal.post(lambda x: x > 0)(lambda x: -x)
    assert func(-4) == 4

    with pytest.raises(deal.PostContractError):
        func(4)