Workaround for super() calls in test_torchinductor_dynamic_shapes (#118586)

Info about super in dynamic classes:
https://stackoverflow.com/questions/71879642/how-to-pass-function-with-super-when-creating-class-dynamically
https://stackoverflow.com/questions/43782944/super-does-not-work-together-with-type-supertype-obj-obj-must-be-an-i

Calling super(TestCase) actually calls TestCase's parent's functions, bypassing TestCase itself's functions

Mainly doing this because it's making disable bot spam

Test: checked locally and check that https://github.com/pytorch/pytorch/issues/117954 actually got skipped

Pull Request resolved: https://github.com/pytorch/pytorch/pull/118586
Approved by: https://github.com/huydhn
This commit is contained in:
Catherine Lee 2024-01-30 21:34:05 +00:00 committed by PyTorch MergeBot
parent 4f5785b6b3
commit f2682e75e6
2 changed files with 9 additions and 1 deletions

View File

@ -23,7 +23,7 @@ from torch.testing._internal.common_utils import (
parametrize, parametrize,
TEST_WITH_ASAN, TEST_WITH_ASAN,
TEST_WITH_ROCM, TEST_WITH_ROCM,
TestCase, TestCaseBase as TestCase,
) )
from torch.testing._internal.inductor_utils import GPU_TYPE, HAS_CPU, HAS_GPU from torch.testing._internal.inductor_utils import GPU_TYPE, HAS_CPU, HAS_GPU

View File

@ -3910,6 +3910,14 @@ This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0"""
return stderr.decode('ascii') return stderr.decode('ascii')
class TestCaseBase(TestCase):
# Calls to super() in dynamically created classes are a bit odd.
# See https://github.com/pytorch/pytorch/pull/118586 for more info
# Subclassing this class and then calling super(TestCaseBase) will run
# TestCase's setUp, tearDown etc functions
pass
def download_file(url, binary=True): def download_file(url, binary=True):
from urllib.parse import urlsplit from urllib.parse import urlsplit
from urllib import request, error from urllib import request, error