mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-05-06 03:24:16 +02:00
Fixes community/py3-stestr tests ref: https://github.com/pytest-dev/pytest/issues/12263#issuecomment-2081434468 ref: https://github.com/mtreinish/stestr/issues/363
23 lines
872 B
Diff
23 lines
872 B
Diff
diff --git a/testtools/testcase.py b/testtools/testcase.py
|
|
index 004fdb5..b8e9010 100644
|
|
--- a/testtools/testcase.py
|
|
+++ b/testtools/testcase.py
|
|
@@ -693,7 +693,17 @@ class TestCase(unittest.TestCase):
|
|
|
|
def _get_test_method(self):
|
|
method_name = getattr(self, '_testMethodName')
|
|
- return getattr(self, method_name)
|
|
+ try:
|
|
+ m = getattr(self, method_name)
|
|
+ except AttributeError:
|
|
+ if method_name != "runTest":
|
|
+ # We allow instantiation with no explicit method name
|
|
+ # but not an *incorrect* or missing method name.
|
|
+ raise ValueError(
|
|
+ "no such test method in %s: %s" % (self.__class__, method_name)
|
|
+ )
|
|
+ else:
|
|
+ return m
|
|
|
|
def _run_test_method(self, result):
|
|
"""Run the test method for this test.
|