Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@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
@deal.raises(ZeroDivisionError)
@deal.offline
def func(do, number):
if do:
http = urllib3.PoolManager()
http.request('GET', 'http://httpbin.org/robots.txt')
yield 1 / number
@deal.raises(ZeroDivisionError)
@deal.pre(lambda a, b: a > 0 and b > 0)
def div(a: int, b: int) -> float:
assert isinstance(a, int)
assert isinstance(b, int)
assert a > 0
assert b > 0
return a / b
@deal.raises(ZeroDivisionError)
@deal.pre(lambda a, b: a > 0)
@deal.pre(lambda a, b: b > 0, message='b must be positive')
def div(a: int, b: int) -> float:
assert isinstance(a, int)
assert isinstance(b, int)
assert a > 0
assert b > 0
return a / b
def test_main(self):
func = deal.raises(ZeroDivisionError)(lambda x: 1 / x)
with self.subTest(text='good'):
with pytest.raises(ZeroDivisionError):
func(0)
with self.subTest(text='good'):
func(2)
func = deal.raises(KeyError)(lambda x: 1 / x)
with self.subTest(text='error'):
with pytest.raises(deal.RaisesContractError):
func(0)
def test_raises_expects_function_to_raise_error():
func = deal.raises(ZeroDivisionError)(lambda x: 1 / x)
with pytest.raises(ZeroDivisionError):
func(0)
func(2)
func = deal.raises(KeyError)(lambda x: 1 / x)
with pytest.raises(deal.RaisesContractError):
func(0)
@deal.raises(ZeroDivisionError)
def func(x):
if x == -1:
raise KeyError
yield 1 / x
@deal.raises()
def f():
a
1 / 0
return getfile(deal)