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

Refactor Result class #51

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Refactor Result class #51

wants to merge 4 commits into from

Conversation

yamt
Copy link
Contributor

@yamt yamt commented Jan 31, 2023

I plan to add "timed out" case to the union later.

todo:

  • update tests
  • update json reporter

I plan to add "timed out" case to the union later.
@yamt yamt marked this pull request as draft January 31, 2023 09:16
@yamt
Copy link
Contributor Author

yamt commented Feb 3, 2023

@loganek do you have any early feedback about the api?

@loganek
Copy link
Collaborator

loganek commented Feb 3, 2023

@loganek do you have any early feedback about the api?

I left a few comments. It looks ok to me in general, although I'm not really sure if we should have yet another type in the Result union for timeout - after all, it is a failure, right?

@@ -14,14 +14,16 @@ class Failure(NamedTuple):
message: str


class Result(NamedTuple):
class Executed(NamedTuple):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
class Executed(NamedTuple):
class ExecutedResult(NamedTuple):

def failed(self) -> bool:
return len(self.failures) > 0

class Skipped(NamedTuple):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
class Skipped(NamedTuple):
class SkippedResult(NamedTuple):

reason: str


Result = Union[Executed, Skipped]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Result = Union[Executed, Skipped]
Result = Union[ExecutedResult, SkippedResult]

failures: List[Failure]

@property
def failed(self) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd keep that property for the Executed class as it abstracts the implementation detail.

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

Successfully merging this pull request may close these issues.

2 participants