From 50a3b6a6a81395106cbbf0f2a80885d4d43a614f Mon Sep 17 00:00:00 2001 From: Heitor Schueroff Date: Wed, 18 Aug 2021 11:30:44 -0700 Subject: [PATCH] Make SkipInfo with expected_failure an XFAIL (#63481) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/63481 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 https://github.com/pytorch/pytorch/blob/30e1c74dc19ae2b622b46ebcdb7972c42775ac80/torch/testing/_internal/common_device_type.py#L879 to an XFAIL is not possible because the decision of whether to decorate is delayed until the wrapper function is called. fixes https://github.com/pytorch/pytorch/issues/63363 Test Plan: Imported from OSS Reviewed By: ZolotukhinM Differential Revision: D30397154 Pulled By: heitorschueroff fbshipit-source-id: c5e4911969ad8667763eec4203dbbc6a51178592 --- torch/testing/_internal/common_methods_invocations.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/torch/testing/_internal/common_methods_invocations.py b/torch/testing/_internal/common_methods_invocations.py index f06d3ce..5d55f0e 100644 --- a/torch/testing/_internal/common_methods_invocations.py +++ b/torch/testing/_internal/common_methods_invocations.py @@ -6,6 +6,7 @@ import copy import operator import random import numbers +import unittest import torch import numpy as np @@ -21,7 +22,7 @@ from torch.testing import \ integral_types_and, all_types, double_types) from .._core import _dispatch_dtypes from torch.testing._internal.common_device_type import \ - (expectedFailure, onlyOnCPUAndCUDA, skipIf, skipCUDAIfNoMagma, skipCUDAIfNoMagmaAndNoCusolver, skipCUDAIfNoCusolver, + (onlyOnCPUAndCUDA, skipCUDAIfNoMagma, skipCUDAIfNoMagmaAndNoCusolver, skipCUDAIfNoCusolver, skipCPUIfNoLapack, skipCPUIfNoFFT, skipCUDAIfRocm, precisionOverride, toleranceOverride, tol) from torch.testing._internal.common_cuda import CUDA11OrLater, SM53OrLater, SM60OrLater from torch.testing._internal.common_utils import \ @@ -86,7 +87,7 @@ class SkipInfo(DecorateInfo): active_if: whether tests matching the above arguments should be skipped 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!") super().__init__(decorators=decorator, cls_name=cls_name, test_name=test_name, device_type=device_type, dtypes=dtypes, active_if=active_if) -- 2.7.4