class TestCount: @pytest.mark.parametrize( "predicate, sized", [ (generic.equal(1), [0]), (numeric.le(3), ("a", "b")), (numeric.ge(3), "abc"), ], ) def test_returns_true_for_size_matching_predicate(self, predicate: Predicate, sized: Sized) -> None: assert collection.count(predicate)(sized) is True @pytest.mark.parametrize( "predicate, sized", [ (generic.equal(1), [0, 0]), (numeric.le(3), ("a", "b", 1, 2)), (numeric.ge(3), "ab"), ], ) def test_returns_false_for_size_failing_predicate(self, predicate: Predicate, sized: Sized) -> None: assert collection.count(predicate)(sized) is False def test_repr_contains_bound_parameter(self): assert_predicate_name_equals(collection.count(numeric.ge(3)), "count(ge(3))")
def test_repr_contains_bound_parameter(self): assert_predicate_name_equals(collection.count(numeric.ge(3)), "count(ge(3))")
def test_returns_false_for_values_below_limit(self) -> None: predicate = numeric.ge(120) assert predicate(119.9999) is False assert predicate(-120) is False assert predicate(119) is False
def test_repr_contains_bound_parameter(self): assert_predicate_name_equals(numeric.ge(10.134), "ge(10.134)")
def test_returns_true_for_values_above_limit(self) -> None: predicate = numeric.ge(120) assert predicate(121) is True assert predicate(120.0001) is True assert predicate(1200) is True assert predicate(120) is True