Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@deal.post(lambda x: x <= 8)
def double(x):
yield x
yield x * 2
yield x * 4
@deal.post(lambda x: x > 0)
async def func(x):
return -x
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)
@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
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)