Skip to content

Commit 48e689b

Browse files
authored
Merge pull request #373 from ncopa/fix-pytest-8.2
Treat methodName="runTest" similar to unittest.TestCase
2 parents 1440276 + b822ca4 commit 48e689b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

testtools/testcase.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,17 @@ def _run_teardown(self, result):
735735

736736
def _get_test_method(self):
737737
method_name = getattr(self, "_testMethodName")
738-
return getattr(self, method_name)
738+
try:
739+
m = getattr(self, method_name)
740+
except AttributeError:
741+
if method_name != "runTest":
742+
# We allow instantiation with no explicit method name
743+
# but not an *incorrect* or missing method name.
744+
raise ValueError(
745+
"no such test method in %s: %s" % (self.__class__, method_name)
746+
)
747+
else:
748+
return m
739749

740750
def _run_test_method(self, result):
741751
"""Run the test method for this test.

0 commit comments

Comments
 (0)