Skip to content

Commit

Permalink
main/py3-testtools: fix compat with pytest 8.2
Browse files Browse the repository at this point in the history
Fixes community/py3-stestr tests

ref: pytest-dev/pytest#12263 (comment)
ref: mtreinish/stestr#363
  • Loading branch information
ncopa committed May 12, 2024
1 parent 8412c1e commit d0bf0a5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
6 changes: 4 additions & 2 deletions main/py3-testtools/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
pkgname=py3-testtools
_pkgname=testtools
pkgver=2.7.1
pkgrel=1
pkgrel=2
pkgdesc="Extensions to the Python standard library unit testing framework"
url="https://pypi.org/project/testtools"
arch="noarch"
license="MIT"
depends="python3 py3-hatch-vcs py3-fixtures"
makedepends="py3-gpep517 py3-setuptools py3-wheel"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz
pytest8.2.patch"
builddir="$srcdir"/$_pkgname-$pkgver
options="!check" # needs community/py3-twisted and testscenarios from pypi

Expand All @@ -28,4 +29,5 @@ package() {

sha512sums="
78af1c2af6f93671074dafedeaaf3ddbcc806e78c3153a3b90f88874c967e34a18cb85e5649b08fabb4ba4ae649eeb401e79c77c3b9233d9eee2a3c2267a4596 testtools-2.7.1.tar.gz
64151feb16be07260758cc9020fa978a1810b8bbe7fc2f56fc5b6ef6f0ce3ae68c092a57280bca4671f3982bac6254db66cc730e3cae67ece1e85eb2f861f19a pytest8.2.patch
"
23 changes: 23 additions & 0 deletions main/py3-testtools/pytest8.2.patch
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.

0 comments on commit d0bf0a5

Please sign in to comment.