From f2682e75e6fd735c4a84afe59eafd541f7643f4a Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Tue, 30 Jan 2024 21:34:05 +0000 Subject: [PATCH] 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 --- test/inductor/test_torchinductor_dynamic_shapes.py | 2 +- torch/testing/_internal/common_utils.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/test/inductor/test_torchinductor_dynamic_shapes.py b/test/inductor/test_torchinductor_dynamic_shapes.py index 76b1809520b..7692dd4abb9 100644 --- a/test/inductor/test_torchinductor_dynamic_shapes.py +++ b/test/inductor/test_torchinductor_dynamic_shapes.py @@ -23,7 +23,7 @@ from torch.testing._internal.common_utils import ( parametrize, TEST_WITH_ASAN, TEST_WITH_ROCM, - TestCase, + TestCaseBase as TestCase, ) from torch.testing._internal.inductor_utils import GPU_TYPE, HAS_CPU, HAS_GPU diff --git a/torch/testing/_internal/common_utils.py b/torch/testing/_internal/common_utils.py index f0caa283193..2a1977cfa1a 100644 --- a/torch/testing/_internal/common_utils.py +++ b/torch/testing/_internal/common_utils.py @@ -3910,6 +3910,14 @@ This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0""" 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): from urllib.parse import urlsplit from urllib import request, error