diff --git a/mmengine/testing/_internal/distributed.py b/mmengine/testing/_internal/distributed.py index b795cc9456..2e1d8952e5 100644 --- a/mmengine/testing/_internal/distributed.py +++ b/mmengine/testing/_internal/distributed.py @@ -88,16 +88,15 @@ def wrapper(self): return types.MethodType(wrapper, self) - # The main process spawns N subprocesses that run the test. - # Constructor patches current instance test method to - # assume the role of the main process and join its subprocesses, - # or run the underlying test function. - def __init__(self, method_name: str = 'runTest') -> None: - super().__init__(method_name) + def setUp(self) -> None: + # The main process spawns N subprocesses that run the test. + # This patches current instance test method to + # assume the role of the main process and join its subprocesses, + # or run the underlying test function. + method_name = self._testMethodName fn = getattr(self, method_name) setattr(self, method_name, self.join_or_run(fn)) - def setUp(self) -> None: super().setUp() self.skip_return_code_checks = [] # type: ignore[var-annotated] self.processes = [] # type: ignore[var-annotated]