Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Remove init due to breaking change in pytest 8.2.0 #1589

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions mmengine/testing/_internal/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,15 @@ 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__}:'
f' {method_name}') from e

def setUp(self) -> None:
super().setUp()
Expand Down Expand Up @@ -345,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:
Expand Down