KEMBAR78
Make SkipInfo with expected_failure an XFAIL by heitorschueroff · Pull Request #63481 · pytorch/pytorch · GitHub
Skip to content

Conversation

@heitorschueroff
Copy link
Contributor

@heitorschueroff heitorschueroff commented Aug 18, 2021

Stack from ghstack:

This PR changes the SkipInfo decorators to use unittest.expectedFailure so that the test reports as XFAIL as opposed to PASSED.

Note that changing the expectedFailure here

class expectedFailure(object):
to an XFAIL is not possible because the decision of whether to decorate is delayed until the wrapper function is called.

fixes #63363

Differential Revision: D30397154

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Aug 18, 2021

🔗 Helpful links

💊 CI failures summary and remediations

As of commit 8d7a34c (more details on the Dr. CI page):


  • 1/1 failures possibly* introduced in this PR
    • 1/1 non-scanned failure(s)

ci.pytorch.org: 1 failed


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

Copy link
Contributor

@zou3519 zou3519 left a comment

Choose a reason for hiding this comment

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

Nice, thank you!

@heitorschueroff
Copy link
Contributor Author

@heitorschueroff has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

expected_failure: whether to assert that skipped tests fail
"""
decorator = expectedFailure(device_type) if expected_failure else skipIf(True, "Skipped!")
decorator = unittest.expectedFailure if expected_failure else unittest.skip("Skipped!")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not wrap the function in the expectedFailure decorator?

fn(slf, *args, **kwargs)

Like could the unittest.expectedFailure decorator be applied to that function before calling it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That won't work. The unittest.expectedFailure is implemented as follows

def expectedFailure(test_item):
    test_item.__unittest_expecting_failure__ = True
    return test_item

So wrapping fn with it will not change the behavior of the function. We need to expose this attribute to the unittest engine.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Aha! You're right. My mistake.

@codecov
Copy link

codecov bot commented Aug 18, 2021

Codecov Report

Merging #63481 (8d7a34c) into gh/heitorschueroff/15/base (d431c77) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

@@                      Coverage Diff                       @@
##           gh/heitorschueroff/15/base   #63481      +/-   ##
==============================================================
- Coverage                       74.45%   74.42%   -0.04%     
==============================================================
  Files                            2118     2118              
  Lines                          212264   212265       +1     
==============================================================
- Hits                           158041   157968      -73     
- Misses                          54223    54297      +74     

@mruberry mruberry self-requested a review August 18, 2021 18:05
@facebook-github-bot
Copy link
Contributor

@heitorschueroff merged this pull request in 50a3b6a.

@facebook-github-bot facebook-github-bot deleted the gh/heitorschueroff/15/head branch August 22, 2021 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants