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

Add properties to TestCase for the two other result-types #136

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Cube707
Copy link

@Cube707 Cube707 commented Oct 10, 2024

This PR adds the two missing properties is_failure and is_error to the TestCase class. They are implemented identically to the existing is_skipped property.

We are using junitparser to fill a table with all testcases and it feels really inconsistent to have three different ways to check for success (directly from propriety), failure (checking two other proprieties are unset) and errors (isinstance check on results). So this Pr would make it much easier and consistent.


created in cooperation with @jonahRo

Comment on lines 367 to 378
@result.setter
def result(self, value: Union[Result, List[Result]]):
# First remove all existing results
for entry in self.result:
if any(isinstance(entry, r) for r in POSSIBLE_RESULTS):
if isinstance(entry, tuple(POSSIBLE_RESULTS)):
self.remove(entry)
if isinstance(value, Result):
self.append(value)
elif isinstance(value, list):
for entry in value:
if any(isinstance(entry, r) for r in POSSIBLE_RESULTS):
if isinstance(entry, tuple(POSSIBLE_RESULTS)):
self.append(entry)
Copy link
Author

@Cube707 Cube707 Oct 24, 2024

Choose a reason for hiding this comment

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

I don't get some of the guard in this code?

if passing in a single value it just needs to inherit from Result but passing a list will ignore all values that are not Failure | Error | Skipped? And why are values potentially not cleared from the previous content of self.result?

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.

1 participant