Skip to content

Commit fcc90c8

Browse files
committed
Fix in backwards compatible way
1 parent c9b5996 commit fcc90c8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

mmengine/testing/_internal/distributed.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,14 @@ def wrapper(self):
9494
# or run the underlying test function.
9595
def __init__(self, method_name: str = 'runTest') -> None:
9696
super().__init__(method_name)
97-
fn = getattr(self, method_name)
98-
setattr(self, method_name, self.join_or_run(fn))
97+
try:
98+
fn = getattr(self, method_name)
99+
setattr(self, method_name, self.join_or_run(fn))
100+
except AttributeError as e:
101+
if method_name != 'runTest':
102+
# we allow instantiation with no explicit method name
103+
# but not an *incorrect* or missing method name
104+
raise ValueError(f"no such test method in {self.__class__}: {method_name}") from e
99105

100106
def setUp(self) -> None:
101107
super().setUp()

0 commit comments

Comments
 (0)