Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider renaming Condition test param to match for consistency with Match #549

Open
yashaka opened this issue Jul 18, 2024 · 0 comments
Open

Comments

@yashaka
Copy link
Owner

yashaka commented Jul 18, 2024

Compare current:

from selene.core.condition import Condition, Match
from selene.core.exceptions import ConditionMismatch

has_positive_number = Condition(
    'has positive number',
    test=ConditionMismatch._to_raise_if_not(
        actual=lambda entity: entity.number,
        by=lambda number: number > 0,
    )
)
# =>
has_positive_number_ = Match(
    'has positive number',
    actual=lambda entity: entity.number,
    by=lambda number: number > 0,
)

to:

from selene.core.condition import Condition, Match
from selene.core.exceptions import ConditionMismatch

has_positive_number = Condition(
    'has positive number',
    match=ConditionMismatch._to_raise_if_not(
        actual=lambda entity: entity.number,
        by=lambda number: number > 0,
    )
)
# =>
has_positive_number_ = Match(
    'has positive number',
    actual=lambda entity: entity.number,
    by=lambda number: number > 0,
)

Then the reason of Match existence becomes easier to understand:)
Who knows, maybe we even have to remove actual and by args of Condition,
or, at least, not remove, but make them private (_actual, _by) and reveal them for usage only in Match as actual and by...

Then we have to consider rething condition.call aliases... And corresponding test vs match naming... We have some kind of conflict between entity.matching(condition) and condition.match(entity), because the term is same, but meaning different – predicate vs assertion... But also the grammatical form is different *ing vs *... So maybe it's ok...

Hm... But look at this: match.visible.match(element) o_O !!! ... match.visible.test(element) looks better... While the match.visible(element) is yet the best one...

Hm... What if we make match.visible.for_(element) to serve as predicate in bool context?"

Test might be also a good candidate over Match ... But Test does not correlate in `entity.should(Test(actual=..., by=...))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant