summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Vaněk <arkamar@gentoo.org>2024-07-08 12:51:18 +0200
committerPetr Vaněk <arkamar@gentoo.org>2024-07-08 12:52:35 +0200
commitb7f0932a01dda0d1d02ccc5417b329d767b4c608 (patch)
treecfc2bb3261aae3e793b70dea589e9132b169ff84 /dev-python
parentdev-perl/IO-Socket-SSL: add 2.87.0 (diff)
downloadgentoo-b7f0932a01dda0d1d02ccc5417b329d767b4c608.tar.gz
gentoo-b7f0932a01dda0d1d02ccc5417b329d767b4c608.tar.bz2
gentoo-b7f0932a01dda0d1d02ccc5417b329d767b4c608.zip
dev-python/python-glanceclient: enable py3.13
Signed-off-by: Petr Vaněk <arkamar@gentoo.org>
Diffstat (limited to 'dev-python')
-rw-r--r--dev-python/python-glanceclient/files/python-glanceclient-4.6.0-test-py3.13.patch66
-rw-r--r--dev-python/python-glanceclient/python-glanceclient-4.6.0.ebuild6
2 files changed, 71 insertions, 1 deletions
diff --git a/dev-python/python-glanceclient/files/python-glanceclient-4.6.0-test-py3.13.patch b/dev-python/python-glanceclient/files/python-glanceclient-4.6.0-test-py3.13.patch
new file mode 100644
index 000000000000..b1760f8b87af
--- /dev/null
+++ b/dev-python/python-glanceclient/files/python-glanceclient-4.6.0-test-py3.13.patch
@@ -0,0 +1,66 @@
+From 6aa007080e1db0f95b04824f42a6b52cbd5ff886 Mon Sep 17 00:00:00 2001
+From: Petr Vaněk <arkamar@atlas.cz>
+Date: Mon, 08 Jul 2024 12:01:15 +0200
+Subject: [PATCH] Python 3.13 test fixes
+
+Python 3.13 newly calls close in mock_open [1], which makes two
+_cache_schemas related tests fail because they expect different amount
+of mock_calls. This fix makes the expected check results conditional
+based on python version.
+
+[1] https://github.com/python/cpython/commit/3f7c0810f6158a7ff37be432f8d7f9511427489f
+
+Change-Id: I8b019f73fe3a9f28f114c95321a1da0feadf750f
+
+Upstream-PR: https://review.opendev.org/c/openstack/python-glanceclient/+/923628
+
+diff --git a/glanceclient/tests/unit/test_shell.py b/glanceclient/tests/unit/test_shell.py
+index 4a123ab..ea835c4 100644
+--- a/glanceclient/tests/unit/test_shell.py
++++ b/glanceclient/tests/unit/test_shell.py
+@@ -786,14 +786,19 @@ class ShellCacheSchemaTest(testutils.TestCase):
+ client = self.shell._get_versioned_client('2', args)
+ self.shell._cache_schemas(args, client, home_dir=self.cache_dir)
+
+- self.assertEqual(12, open.mock_calls.__len__())
++ # see https://github.com/python/cpython/commit/3f7c0810f6158a7ff37be432f8d7f9511427489f
++ expected_count = 12 if sys.version_info < (3, 13) else 15
++ open_idx = 4 if sys.version_info < (3, 13) else 5
++ write_idx = 6 if sys.version_info < (3, 13) else 7
++
++ self.assertEqual(expected_count, open.mock_calls.__len__())
+ self.assertEqual(mock.call(self.cache_files[0], 'w'),
+ open.mock_calls[0])
+ self.assertEqual(mock.call(self.cache_files[1], 'w'),
+- open.mock_calls[4])
++ open.mock_calls[open_idx])
+ actual = json.loads(open.mock_calls[2][1][0])
+ self.assertEqual(schema_odict, actual)
+- actual = json.loads(open.mock_calls[6][1][0])
++ actual = json.loads(open.mock_calls[write_idx][1][0])
+ self.assertEqual(schema_odict, actual)
+
+ @mock.patch('builtins.open', new=mock.mock_open(), create=True)
+@@ -809,14 +814,19 @@ class ShellCacheSchemaTest(testutils.TestCase):
+ client = self.shell._get_versioned_client('2', args)
+ self.shell._cache_schemas(args, client, home_dir=self.cache_dir)
+
+- self.assertEqual(12, open.mock_calls.__len__())
++ # see https://github.com/python/cpython/commit/3f7c0810f6158a7ff37be432f8d7f9511427489f
++ expected_count = 12 if sys.version_info < (3, 13) else 15
++ open_idx = 4 if sys.version_info < (3, 13) else 5
++ write_idx = 6 if sys.version_info < (3, 13) else 7
++
++ self.assertEqual(expected_count, open.mock_calls.__len__())
+ self.assertEqual(mock.call(self.cache_files[0], 'w'),
+ open.mock_calls[0])
+ self.assertEqual(mock.call(self.cache_files[1], 'w'),
+- open.mock_calls[4])
++ open.mock_calls[open_idx])
+ actual = json.loads(open.mock_calls[2][1][0])
+ self.assertEqual(schema_odict, actual)
+- actual = json.loads(open.mock_calls[6][1][0])
++ actual = json.loads(open.mock_calls[write_idx][1][0])
+ self.assertEqual(schema_odict, actual)
+
+ @mock.patch('builtins.open', new=mock.mock_open(), create=True)
diff --git a/dev-python/python-glanceclient/python-glanceclient-4.6.0.ebuild b/dev-python/python-glanceclient/python-glanceclient-4.6.0.ebuild
index d1666fba6eca..b1ca97d43703 100644
--- a/dev-python/python-glanceclient/python-glanceclient-4.6.0.ebuild
+++ b/dev-python/python-glanceclient/python-glanceclient-4.6.0.ebuild
@@ -5,7 +5,7 @@ EAPI=8
DISTUTILS_USE_PEP517=setuptools
PYPI_NO_NORMALIZE=1
-PYTHON_COMPAT=( python3_{10..12} )
+PYTHON_COMPAT=( python3_{10..13} )
inherit distutils-r1 pypi
@@ -50,6 +50,10 @@ PATCHES=(
# https://bugs.launchpad.net/python-glanceclient/+bug/2069684
# https://bugs.launchpad.net/python-glanceclient/+bug/2069682
"${FILESDIR}/${P}-test.patch"
+
+ # py3.13 added close() to mock_open calls
+ # https://review.opendev.org/c/openstack/python-glanceclient/+/923628
+ "${FILESDIR}/${P}-test-py3.13.patch"
)
python_test() {