def test_has_stderr(markers: list, expected: bool): assert deal.has(*markers).has_stderr is expected
def test_has_import(markers: list, expected: bool): assert deal.has(*markers).has_import is expected
def test_has_network(markers: list, expected: bool): assert deal.has(*markers).has_network is expected
def test_has_write(markers: list, expected: bool): assert deal.has(*markers).has_write is expected
def test_has_read(markers: list, expected: bool): assert deal.has(*markers).has_read is expected
def test_has_global(markers: list, expected: bool): assert deal.has(*markers).has_global is expected
# element at this position matches item deal.ensure( lambda items, item, result: items[result] == item, message='invalid match', ), # element at this position is the first match deal.ensure( lambda items, item, result: not any(el == item for el in items[:result]), message='not the first match', ), # LookupError will be raised if no elements found deal.raises(LookupError), deal.reason(LookupError, lambda items, item: item not in items), # no side-effects deal.has(), ) @contract_for_index_of def index_of(items: List[int], item: int) -> int: for index, el in enumerate(items): if el == item: return index raise LookupError @pytest.mark.parametrize('case', deal.cases(index_of)) def test_index_of(case): case()