commit:     2b4b2f5a8cb8d9c88318cc39e69b088de45f8b15
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 29 10:47:57 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Oct 29 11:10:03 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2b4b2f5a

dev-python/braintree: Enable py3.12

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/braintree/braintree-4.23.0.ebuild       |  7 +-
 .../braintree/files/braintree-4.23.0-py312.patch   | 81 ++++++++++++++++++++++
 2 files changed, 87 insertions(+), 1 deletion(-)

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?= <mgo...@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
+

Reply via email to