-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
main/py3-testtools: fix compat with pytest 8.2
Fixes community/py3-stestr tests ref: pytest-dev/pytest#12263 (comment) ref: mtreinish/stestr#363
- Loading branch information
Showing
2 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
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. |