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

raise value error from the constructor level #290

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions testslide/matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class _AndMatcher(_AlreadyChainedMatcher):
"""

def __init__(self, a: Matcher, b: Matcher) -> None:
if not isinstance(a, Matcher) or not isinstance(b, Matcher):
raise ValueError("Not of type Matcher")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. I would have more explicit wording in here eventually pointing to what is not a Matcher. Like adding the presentation of a or b.
This would help developers receiving such error to be guided toward what to fix instead of having them discover it themselves

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes am working on it.

self.a = a
self.b = b

Expand All @@ -65,6 +67,8 @@ def __repr__(self) -> str:

class _XorMatcher(_AlreadyChainedMatcher):
def __init__(self, a: Matcher, b: Matcher) -> None:
if not isinstance(a, Matcher) or not isinstance(b, Matcher):
raise ValueError("Not of type Matcher")
self.a = a
self.b = b

Expand All @@ -90,6 +94,8 @@ def __repr__(self) -> str:

class _OrMatcher(_AlreadyChainedMatcher):
def __init__(self, a: Matcher, b: Matcher) -> None:
if not isinstance(a, Matcher) or not isinstance(b, Matcher):
raise ValueError("Not of type Matcher")
self.a = a
self.b = b

Expand Down