Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_return_type_checks(self):
def div(a: int, b: int):
return 1
for case in deal.cases(div, count=20):
case()
def div(a: int, b: int) -> str:
return 1
with pytest.raises(TypeError):
case = next(iter(deal.cases(div, count=20)))
case()
def test_params_detected(self):
for case in deal.cases(self.func, count=10):
assert set(case.kwargs) == {'a', 'b'}
def test_count(self):
for count in (1, 10, 20, 50):
cases = deal.cases(self.func, count=count)
assert len(list(cases)) == count
def test_params_type():
for case in deal.cases(func, count=10):
assert type(case.kwargs['a']) is int
assert type(case.kwargs['b']) is int
def test_params_ok_with_excs(self):
results = []
for case in deal.cases(self.func, count=20):
result = case()
results.append(result)
assert any(r is not NoReturn for r in results), 'exception occured on every run'
assert any(r is NoReturn for r in results), 'no exception occured'
def test_explicit_kwargs():
def div(a: int, b: int):
assert b == 4
for case in deal.cases(div, kwargs=dict(b=4), count=20):
case()
def test_params_ok_with_excs():
results = []
for case in deal.cases(func, count=20):
result = case()
results.append(result)
assert any(r is NoReturn for r in results), 'no exception occured'
def test_return_type_checks(self):
def div(a: int, b: int):
return 1
for case in deal.cases(div, count=20):
case()
def div(a: int, b: int) -> str:
return 1
with pytest.raises(TypeError):
case = next(iter(deal.cases(div, count=20)))
case()
@pytest.mark.parametrize('case', deal.cases(concat))
def test_concat(case):
case()