Repository: braintree/braintree_python (language: python)

Issue:
Unittest failures on Python 3.12
### General information

* SDK/Library version: 4.23.0
* Environment: n/a
* Language, language version, and OS: Python 3.12.0 on Gentoo amd64

### Issue description

When running the test suite on Python 3.12, I'm getting the following failures:

```pytb
$ python -m unittest discover tests/unit
..............................E.E.........................................................................................................................................................................................................................................................................................................................................................
======================================================================
ERROR: test_credit_card_options_require_customer_id (test_client_token.TestClientToken.test_credit_card_options_require_customer_id)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/braintree_python/tests/unit/test_client_token.py", line 6, in test_credit_card_options_require_customer_id
    with self.assertRaisesRegexp(InvalidSignatureError, option):
         ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TestClientToken' object has no attribute 'assertRaisesRegexp'. Did you mean: 'assertRaisesRegex'?

======================================================================
ERROR: test_configuration (unittest.loader._FailedTest.test_configuration)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_configuration
Traceback (most recent call last):
  File "/usr/lib/python3.12/unittest/loader.py", line 382, in _find_test_path
    module = self._get_module_from_name(name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/unittest/loader.py", line 325, in _get_module_from_name
    __import__(name)
  File "/tmp/braintree_python/tests/unit/test_configuration.py", line 4, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'


----------------------------------------------------------------------
Ran 378 tests in 0.063s

FAILED (errors=2)
```

The first one is merely a matter of replacing it with `assertRaisesRegex()` (works since Python 3.2), the second one seems to require replacing `imp` with `importlib` (which has a `reload()` function as well). I can submit a PR if you wish.


Discussion / hints:

Fix patch:
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:


Test patch:
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 @@
 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 @@ def test_works_with_unconfigured_configuration(self):
         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())