From fcc90c81345a5d5acded926de7a5e11c78ac7076 Mon Sep 17 00:00:00 2001 From: Tibor Reiss Date: Wed, 23 Oct 2024 22:34:01 +0200 Subject: [PATCH 1/2] Fix in backwards compatible way --- mmengine/testing/_internal/distributed.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mmengine/testing/_internal/distributed.py b/mmengine/testing/_internal/distributed.py index b795cc9456..0d602a3964 100644 --- a/mmengine/testing/_internal/distributed.py +++ b/mmengine/testing/_internal/distributed.py @@ -94,8 +94,14 @@ def wrapper(self): # or run the underlying test function. def __init__(self, method_name: str = 'runTest') -> None: super().__init__(method_name) - fn = getattr(self, method_name) - setattr(self, method_name, self.join_or_run(fn)) + try: + fn = getattr(self, method_name) + setattr(self, method_name, self.join_or_run(fn)) + except AttributeError as e: + if method_name != 'runTest': + # we allow instantiation with no explicit method name + # but not an *incorrect* or missing method name + raise ValueError(f"no such test method in {self.__class__}: {method_name}") from e def setUp(self) -> None: super().setUp() From 2d5539073392ae799606447bbd0a44a37a1fa078 Mon Sep 17 00:00:00 2001 From: Tibor Reiss Date: Wed, 23 Oct 2024 22:37:04 +0200 Subject: [PATCH 2/2] Do not skip if exited properly --- mmengine/testing/_internal/distributed.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mmengine/testing/_internal/distributed.py b/mmengine/testing/_internal/distributed.py index 0d602a3964..5f3dffa810 100644 --- a/mmengine/testing/_internal/distributed.py +++ b/mmengine/testing/_internal/distributed.py @@ -101,7 +101,8 @@ def __init__(self, method_name: str = 'runTest') -> None: if method_name != 'runTest': # we allow instantiation with no explicit method name # but not an *incorrect* or missing method name - raise ValueError(f"no such test method in {self.__class__}: {method_name}") from e + raise ValueError(f'no such test method in {self.__class__}:' + f' {method_name}') from e def setUp(self) -> None: super().setUp() @@ -351,12 +352,13 @@ def _check_return_codes(self, elapsed_time) -> None: if first_process.exitcode == skip.exit_code: raise unittest.SkipTest(skip.message) - # Skip the unittest since the raised error maybe not caused by - # the tested function. For example, in CI environment, the tested - # method could be terminated by system signal for the limited - # resources. - self.skipTest(f'Skip test {self._testMethodName} due to ' - 'the program abort') + if first_process.exitcode != 0: + # Skip the unittest since the raised error maybe not caused by + # the tested function. For example, in CI environment, the tested + # method could be terminated by system signal for the limited + # resources. + self.skipTest(f'Skip test {self._testMethodName} due to ' + 'the program abort') @property def is_master(self) -> bool: