Predicates¶
between ¶
between(
inf_bound: Comparison,
sup_bound: Comparison,
exclude: bool = False,
) -> Predicate[Comparison]
Returns a between predicate.
Corresponding to inf_bound < x < sup_bound if exclude, otherwise inf_bound <= x <= sup_bound.
contains ¶
Returns a predicate to verify if value contains all the items.
Examples:
>>> contain = contains("1", "2", "3")
>>> assert contain(["1", "2", "3", "4"])
>>> assert contain("456123")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
T
|
items to check presence |
()
|
Raises: ValueError: if no item has been passed
equals ¶
ge ¶
Returns a predicate corresponding to x >= bound.
is_blank_str ¶
is_falsy ¶
is_length ¶
is_truthy ¶
le ¶
Returns a predicate corresponding to x <= bound.
match_regex ¶
Returns a predicate that checks if value match the regex pattern provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
regex
|
Union[Pattern[str], str]
|
regex to match (either a string or a Pattern) |
required |
flags
|
Union[RegexFlag, int]
|
regex flags; should bot be passed with a pattern. |
0
|
Raises:
| Type | Description |
|---|---|
TypeError
|
when passing flags whereas a |
neg ¶
Create a new predicate that is the negation of the provided.
If the predicate would yield True, the negated one would yield False, and vice versa.
Examples:
>>> assert maybe("maypy").filter(is_blank_str).is_empty()
>>> assert maybe("maypy").filter(neg(is_blank_str)).is_present()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predicate
|
Predicate[T]
|
preddicate to negate |
required |
Returns:
| Type | Description |
|---|---|
Predicate[T]
|
Negate predicate of the provided |