-
Notifications
You must be signed in to change notification settings - Fork 23
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
fix: Allow subtests to xfail #40
Conversation
I don't really know why this doesn't work. FWICT there is some stuff in https://github.com/pytest-dev/pytest/blob/c198a7a67ead8f4b1933d74c2c7a7f7ede93d284/src/_pytest/skipping.py#L269-L272 which is supposed to handle translation of the |
70fbec1
to
b66b5c7
Compare
b66b5c7
to
f06298d
Compare
Okay, I think I worked out a nice approach for fixing this issue :) Let me know what you think and if this is mergable or needs more work. |
Thanks @maybe-sybr! I will review it ASAP, thanks a lot for the contribution, appreciate it. 👍 |
I'll fix the lint issue now :) |
This change ensures that all `makereport` hooks get called prior to subtests transforming the constructed `TestReport` to a `SubTestReport`. A test is added for pytest style usage and an xfailing test is added for unittest style since the same issue affecting skip counting is present for xfail counting. Fixes pytest-dev#24
f06298d
to
b03438d
Compare
@@ -71,14 +71,19 @@ def _from_json(cls, reportdict): | |||
) | |||
return report | |||
|
|||
@classmethod | |||
def _from_test_report(cls, test_report): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI made this private users from using it (at least for now).
|
||
def _addSubTest(self, test_case, test, exc_info): | ||
if exc_info is not None: | ||
msg = test._message if isinstance(test._message, str) else None | ||
call_info = make_call_info( | ||
ExceptionInfo(exc_info), start=0, stop=0, duration=0, when="call" | ||
) | ||
sub_report = SubTestReport.from_item_and_call(item=self, call=call_info) | ||
report = self.ihook.pytest_runtest_makereport(item=self, call=call_info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clever solution! 😁
Thanks for the merge @nicoddemus :) |
Sure, and thanks for the contribution! 👍 |
This change ensures that all
makereport
hooks get called prior tosubtests transforming the constructed
TestReport
to aSubTestReport
.A test is added for pytest style usage and an xfailing test is added for
unittest style since the same issue affecting skip counting is present
for xfail counting.
Fixes #24