commit:     cbf0ba8d926be7101a8d7cbf19cd2061dbc8584c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Nov  6 13:07:41 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Nov  6 13:22:30 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cbf0ba8d

dev-python/isort: Enable py3.12

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

 dev-python/isort/files/isort-5.12.0-py312.patch | 40 +++++++++++++++++++++++++
 dev-python/isort/isort-5.12.0.ebuild            |  7 ++++-
 2 files changed, 46 insertions(+), 1 deletion(-)

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?= <[email protected]>
+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

Reply via email to