summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2023-10-29 11:47:57 +0100
committerMichał Górny <mgorny@gentoo.org>2023-10-29 12:10:03 +0100
commit2b4b2f5a8cb8d9c88318cc39e69b088de45f8b15 (patch)
treeb63891f1e51bb81b3c5ad49afa72b3cb371b0ca9 /dev-python/braintree
parentdev-python/docker: Add py3.12 note (diff)
downloadgentoo-2b4b2f5a8cb8d9c88318cc39e69b088de45f8b15.tar.gz
gentoo-2b4b2f5a8cb8d9c88318cc39e69b088de45f8b15.tar.bz2
gentoo-2b4b2f5a8cb8d9c88318cc39e69b088de45f8b15.zip
dev-python/braintree: Enable py3.12
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python/braintree')
-rw-r--r--dev-python/braintree/braintree-4.23.0.ebuild7
-rw-r--r--dev-python/braintree/files/braintree-4.23.0-py312.patch81
2 files changed, 87 insertions, 1 deletions
diff --git a/dev-python/braintree/braintree-4.23.0.ebuild b/dev-python/braintree/braintree-4.23.0.ebuild
index c50e26d97b9e..06d433d74228 100644
--- a/dev-python/braintree/braintree-4.23.0.ebuild
+++ b/dev-python/braintree/braintree-4.23.0.ebuild
@@ -4,7 +4,7 @@
EAPI=8
DISTUTILS_USE_PEP517=setuptools
-PYTHON_COMPAT=( python3_{10..11} )
+PYTHON_COMPAT=( python3_{10..12} )
inherit distutils-r1
@@ -34,6 +34,11 @@ DOCS=( README.md )
distutils_enable_tests unittest
+PATCHES=(
+ # https://github.com/braintree/braintree_python/pull/154
+ "${FILESDIR}/${P}-py312.patch"
+)
+
python_test() {
eunittest tests/unit
}
diff --git a/dev-python/braintree/files/braintree-4.23.0-py312.patch b/dev-python/braintree/files/braintree-4.23.0-py312.patch
new file mode 100644
index 000000000000..4ecbd9e555dd
--- /dev/null
+++ b/dev-python/braintree/files/braintree-4.23.0-py312.patch
@@ -0,0 +1,81 @@
+From 9fbdf874ef6a6874db5e98cb2c93ab9736810d4e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Sun, 29 Oct 2023 11:18:56 +0100
+Subject: [PATCH] Fix test suite compatibility with Python 3.12
+
+Replace the deprecated `unittest.TestCase.assertRaisesRegexp()` method
+with `assertRaisesRegex()`. The former is no longer present in Python
+3.12, while the latter is available since Python 3.2.
+
+Replace the deprecated `imp.reload()` function with
+`importlib.reload()`. The former module is no longer present
+in Python 3.12, while `importlib.reload()` is available since
+Python 3.4.
+
+With these changes, unit tests pass with Python 3.12.0.
+
+Fixes #153
+---
+ CHANGELOG.md | 3 +++
+ tests/unit/test_client_token.py | 2 +-
+ tests/unit/test_configuration.py | 6 +++---
+ 3 files changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/CHANGELOG.md b/CHANGELOG.md
+index 56e4373..792ee9c 100644
+--- a/CHANGELOG.md
++++ b/CHANGELOG.md
+@@ -1,5 +1,8 @@
+ # Changelog
+
++## 4.24.0
++* Fix unittest compatibility with Python 3.12
++
+ ## 4.23.0
+ * Deprecate `evidenceSubmittable` in Dispute
+ * Add missing `escape` calls in `generator` for:
+diff --git a/tests/unit/test_client_token.py b/tests/unit/test_client_token.py
+index 7216a6b..74eb8a2 100644
+--- a/tests/unit/test_client_token.py
++++ b/tests/unit/test_client_token.py
+@@ -3,7 +3,7 @@ from tests.test_helper import *
+ class TestClientToken(unittest.TestCase):
+ def test_credit_card_options_require_customer_id(self):
+ for option in ["verify_card", "make_default", "fail_on_duplicate_payment_method"]:
+- with self.assertRaisesRegexp(InvalidSignatureError, option):
++ with self.assertRaisesRegex(InvalidSignatureError, option):
+ ClientToken.generate({
+ "options": {option: True}
+ })
+diff --git a/tests/unit/test_configuration.py b/tests/unit/test_configuration.py
+index cf82831..5b24540 100644
+--- a/tests/unit/test_configuration.py
++++ b/tests/unit/test_configuration.py
+@@ -1,13 +1,13 @@
+ from tests.test_helper import *
+ import braintree
+ import os
+-import imp
++import importlib
+
+ class TestConfiguration(unittest.TestCase):
+ def test_works_with_unconfigured_configuration(self):
+ try:
+ # reset class level attributes on Configuration set in test helper
+- imp.reload(braintree.configuration)
++ importlib.reload(braintree.configuration)
+ config = Configuration(
+ environment=braintree.Environment.Sandbox,
+ merchant_id='my_merchant_id',
+@@ -21,7 +21,7 @@ class TestConfiguration(unittest.TestCase):
+ finally:
+ # repopulate class level attributes on Configuration
+ import tests.test_helper
+- imp.reload(tests.test_helper)
++ importlib.reload(tests.test_helper)
+
+ def test_base_merchant_path_for_development(self):
+ self.assertEqual("/merchants/integration_merchant_id", Configuration.instantiate().base_merchant_path())
+--
+2.42.0
+