summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2023-11-06 14:07:41 +0100
committerMichał Górny <mgorny@gentoo.org>2023-11-06 14:22:30 +0100
commitcbf0ba8d926be7101a8d7cbf19cd2061dbc8584c (patch)
treead24ca16de986a270d783c29adf9ec7e5b88f9d7 /dev-python/isort
parentdev-python/isort: Remove test dep on dev-python/pylama (diff)
downloadgentoo-cbf0ba8d926be7101a8d7cbf19cd2061dbc8584c.tar.gz
gentoo-cbf0ba8d926be7101a8d7cbf19cd2061dbc8584c.tar.bz2
gentoo-cbf0ba8d926be7101a8d7cbf19cd2061dbc8584c.zip
dev-python/isort: Enable py3.12
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python/isort')
-rw-r--r--dev-python/isort/files/isort-5.12.0-py312.patch40
-rw-r--r--dev-python/isort/isort-5.12.0.ebuild7
2 files changed, 46 insertions, 1 deletions
diff --git a/dev-python/isort/files/isort-5.12.0-py312.patch b/dev-python/isort/files/isort-5.12.0-py312.patch
new file mode 100644
index 000000000000..a6de4a75311b
--- /dev/null
+++ b/dev-python/isort/files/isort-5.12.0-py312.patch
@@ -0,0 +1,40 @@
+From abfb91fd7da34111828d81a20fe7aeaaab7a58c7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Mon, 6 Nov 2023 13:29:21 +0100
+Subject: [PATCH] Fix assertions in `test_git_hook`
+
+Fix `called_once()` assertions in `test_git_hook` to use the correct
+`assert_called_once()` method. The former does not exist, so it
+evaluates to a mocked method in Python < 3.12, making the assert
+meaningless, and it triggers an error in Python 3.12+.
+
+While at it, split the mock into two because otherwise the test would
+fail because two `hooks.git_hook()` calls imply two mock calls.
+---
+ tests/unit/test_hooks.py | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/tests/unit/test_hooks.py b/tests/unit/test_hooks.py
+index 2757f414f..29685f503 100644
+--- a/tests/unit/test_hooks.py
++++ b/tests/unit/test_hooks.py
+@@ -11,7 +11,7 @@ def test_git_hook(src_dir):
+ # Ensure correct subprocess command is called
+ with patch("subprocess.run", MagicMock()) as run_mock:
+ hooks.git_hook()
+- assert run_mock.called_once()
++ run_mock.assert_called_once()
+ assert run_mock.call_args[0][0] == [
+ "git",
+ "diff-index",
+@@ -21,8 +21,9 @@ def test_git_hook(src_dir):
+ "HEAD",
+ ]
+
++ with patch("subprocess.run", MagicMock()) as run_mock:
+ hooks.git_hook(lazy=True)
+- assert run_mock.called_once()
++ run_mock.assert_called_once()
+ assert run_mock.call_args[0][0] == [
+ "git",
+ "diff-index",
diff --git a/dev-python/isort/isort-5.12.0.ebuild b/dev-python/isort/isort-5.12.0.ebuild
index 6a9a23af7de4..e3f28e100a52 100644
--- a/dev-python/isort/isort-5.12.0.ebuild
+++ b/dev-python/isort/isort-5.12.0.ebuild
@@ -4,7 +4,7 @@
EAPI=8
DISTUTILS_USE_PEP517=poetry
-PYTHON_COMPAT=( python3_{10..11} )
+PYTHON_COMPAT=( python3_{10..12} )
inherit distutils-r1
@@ -39,6 +39,11 @@ BDEPEND="
distutils_enable_tests pytest
src_prepare() {
+ local PATCHES=(
+ # https://github.com/PyCQA/isort/pull/2196
+ "${FILESDIR}/${P}-py312.patch"
+ )
+
# unbundle tomli
sed -i -e 's:from ._vendored ::' isort/settings.py || die
rm -r isort/_vendored || die