Second attempt to fix KeyError: 'console_scripts'
The fix allows us to no longer skip the previously skipped tests.
This commit is contained in:
parent
b9899f1d9a
commit
856a4a0af9
@ -1,42 +0,0 @@
|
|||||||
From 1c75d61d662126d861e3055db9f7619d5d374682 Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
|
||||||
Date: Wed, 28 Jun 2023 18:50:56 +0200
|
|
||||||
Subject: [PATCH] Skip tests that fail on Python 3.12
|
|
||||||
|
|
||||||
---
|
|
||||||
test/test.py | 4 ++++
|
|
||||||
1 file changed, 4 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/test/test.py b/test/test.py
|
|
||||||
index 75e281c..26808e1 100755
|
|
||||||
--- a/test/test.py
|
|
||||||
+++ b/test/test.py
|
|
||||||
@@ -1288,21 +1288,25 @@ class TestBashGlobal(TestBash):
|
|
||||||
self.assertEqual(self.sh.run_command(command), 'arg\r\n')
|
|
||||||
|
|
||||||
@unittest.skipIf(os.uname()[0] == "Darwin", "Skip test that fails on MacOS")
|
|
||||||
+ @unittest.skipIf(sys.version_info >= (3, 12), "Skip test that fails on Python 3.12")
|
|
||||||
def test_console_script_module(self):
|
|
||||||
"""Test completing a console_script for a module."""
|
|
||||||
self._test_console_script()
|
|
||||||
|
|
||||||
@unittest.skipIf(os.uname()[0] == "Darwin", "Skip test that fails on MacOS")
|
|
||||||
+ @unittest.skipIf(sys.version_info >= (3, 12), "Skip test that fails on Python 3.12")
|
|
||||||
def test_console_script_package(self):
|
|
||||||
"""Test completing a console_script for a package."""
|
|
||||||
self._test_console_script(package=True)
|
|
||||||
|
|
||||||
@unittest.skipIf(os.uname()[0] == "Darwin", "Skip test that fails on MacOS")
|
|
||||||
+ @unittest.skipIf(sys.version_info >= (3, 12), "Skip test that fails on Python 3.12")
|
|
||||||
def test_console_script_module_wheel(self):
|
|
||||||
"""Test completing a console_script for a module from a wheel."""
|
|
||||||
self._test_console_script(wheel=True)
|
|
||||||
|
|
||||||
@unittest.skipIf(os.uname()[0] == "Darwin", "Skip test that fails on MacOS")
|
|
||||||
+ @unittest.skipIf(sys.version_info >= (3, 12), "Skip test that fails on Python 3.12")
|
|
||||||
def test_console_script_package_wheel(self):
|
|
||||||
"""Test completing a console_script for a package from a wheel."""
|
|
||||||
self._test_console_script(package=True, wheel=True)
|
|
||||||
--
|
|
||||||
2.40.1
|
|
||||||
|
|
@ -0,0 +1,64 @@
|
|||||||
|
From d0fbcd20a24114fab5b6df71e86065b9a7c7576d Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
||||||
|
Date: Thu, 14 Sep 2023 14:20:27 +0200
|
||||||
|
Subject: [PATCH] Ensure Python 3.12+ compatibility in check_console_script
|
||||||
|
|
||||||
|
In f4d046c0cec1dab17f65853442b1da7d341e2915 an assumption was made
|
||||||
|
(correct at the time), that only the importlib.metadata backport,
|
||||||
|
`importlib_metadata`, returns a tuple of entry points.
|
||||||
|
|
||||||
|
However, importlib.metadata in Python 3.12+ behaves the same.
|
||||||
|
|
||||||
|
This caused a KeyError exception to be thrown on Python 3.12,
|
||||||
|
as reported repeatedly be testers of Fedora Linux 39 in:
|
||||||
|
|
||||||
|
https://bugzilla.redhat.com/show_bug.cgi?id=2231593
|
||||||
|
|
||||||
|
This change adjusts the conditional used in check_console_script
|
||||||
|
to assume both the backport and Python 3.12+ return a tuple.
|
||||||
|
|
||||||
|
While not obvious from the test failures output,
|
||||||
|
this change also fixes the following TestBashGlobal tests failures:
|
||||||
|
|
||||||
|
- test_console_script_module
|
||||||
|
- test_console_script_module_wheel
|
||||||
|
- test_console_script_package
|
||||||
|
- test_console_script_package_wheel
|
||||||
|
|
||||||
|
For the reference, the failures looked like this:
|
||||||
|
|
||||||
|
FAIL: test_console_script_module (__main__.TestBashGlobal.test_console_script_module)
|
||||||
|
Test completing a console_script for a module.
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File ".../argcomplete/test/test.py", line 1376, in test_console_script_module
|
||||||
|
self._test_console_script()
|
||||||
|
File ".../argcomplete/test/test.py", line 1370, in _test_console_script
|
||||||
|
self.assertEqual(self.sh.run_command(command), "arg\r\n")
|
||||||
|
AssertionError: "usage: test-module [-h] {arg}\r\ntest-mo[66 chars]\r\n" != 'arg\r\n'
|
||||||
|
+ arg
|
||||||
|
- usage: test-module [-h] {arg}
|
||||||
|
- test-module: error: argument arg: invalid choice: 'a' (choose from 'arg')
|
||||||
|
|
||||||
|
Fixes https://github.com/kislyuk/argcomplete/issues/440
|
||||||
|
---
|
||||||
|
argcomplete/_check_console_script.py | 3 ++-
|
||||||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/argcomplete/_check_console_script.py b/argcomplete/_check_console_script.py
|
||||||
|
index 3f838e4..7bbe59a 100644
|
||||||
|
--- a/argcomplete/_check_console_script.py
|
||||||
|
+++ b/argcomplete/_check_console_script.py
|
||||||
|
@@ -38,7 +38,8 @@ def main():
|
||||||
|
|
||||||
|
# The importlib_metadata backport returns a tuple of entry point objects
|
||||||
|
# whereas the official library returns a SelectableGroups object
|
||||||
|
- if not use_entry_points_backport:
|
||||||
|
+ # Python 3.12+ behaves like the importlib_metadata backport
|
||||||
|
+ if not use_entry_points_backport and sys.version_info < (3, 12):
|
||||||
|
entry_points = entry_points["console_scripts"]
|
||||||
|
|
||||||
|
entry_points = [ep for ep in entry_points \
|
||||||
|
--
|
||||||
|
2.41.0
|
||||||
|
|
@ -8,7 +8,7 @@
|
|||||||
Name: python-argcomplete
|
Name: python-argcomplete
|
||||||
Summary: Bash tab completion for argparse
|
Summary: Bash tab completion for argparse
|
||||||
Version: 2.0.0
|
Version: 2.0.0
|
||||||
Release: 11%{?dist}
|
Release: 12%{?dist}
|
||||||
License: ASL 2.0
|
License: ASL 2.0
|
||||||
URL: https://github.com/kislyuk/argcomplete
|
URL: https://github.com/kislyuk/argcomplete
|
||||||
Source0: %pypi_source argcomplete
|
Source0: %pypi_source argcomplete
|
||||||
@ -17,16 +17,16 @@ Source0: %pypi_source argcomplete
|
|||||||
# this patch removes it
|
# this patch removes it
|
||||||
Patch1: 0001-Remove-commit-hash-from-Fish-version.patch
|
Patch1: 0001-Remove-commit-hash-from-Fish-version.patch
|
||||||
|
|
||||||
# Some tests fail with Python 3.12
|
|
||||||
# This has been reported upstream: https://github.com/kislyuk/argcomplete/issues/440
|
|
||||||
# Upstream already skips those on MacOS, so we skip them as well
|
|
||||||
Patch2: 0002-Skip-tests-that-fail-on-Python-3.12.patch
|
|
||||||
|
|
||||||
# Ensure Python 3.7+ compatibility in check_console_script
|
# Ensure Python 3.7+ compatibility in check_console_script
|
||||||
# Rebased from https://github.com/kislyuk/argcomplete/commit/f4d046c0ce
|
# Rebased from https://github.com/kislyuk/argcomplete/commit/f4d046c0ce
|
||||||
# Should fix https://bugzilla.redhat.com/2231593
|
# Partial fix for https://bugzilla.redhat.com/2231593
|
||||||
Patch3: 0003-Ensure-Python-3.7-compatibility-in-check_console_script.patch
|
Patch3: 0003-Ensure-Python-3.7-compatibility-in-check_console_script.patch
|
||||||
|
|
||||||
|
# Ensure Python 3.12+ compatibility in check_console_script
|
||||||
|
# Rebased from https://github.com/kislyuk/argcomplete/pull/448
|
||||||
|
# A second part of the fix for https://bugzilla.redhat.com/2231593
|
||||||
|
Patch4: 0004-Ensure-Python-3.12-compatibility-in-check_console_script.patch
|
||||||
|
|
||||||
BuildRequires: python3-devel
|
BuildRequires: python3-devel
|
||||||
BuildRequires: python3-setuptools
|
BuildRequires: python3-setuptools
|
||||||
|
|
||||||
@ -101,6 +101,10 @@ export INPUTRC=$PWD/.inputrc
|
|||||||
%{_sysconfdir}/bash_completion.d/%{name}
|
%{_sysconfdir}/bash_completion.d/%{name}
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Sep 14 2023 Miro Hrončok <mhroncok@redhat.com> - 2.0.0-12
|
||||||
|
- Second attempt to fix KeyError: 'console_scripts'
|
||||||
|
- Fixes: rhbz#2231593
|
||||||
|
|
||||||
* Sun Aug 13 2023 Miro Hrončok <mhroncok@redhat.com> - 2.0.0-11
|
* Sun Aug 13 2023 Miro Hrončok <mhroncok@redhat.com> - 2.0.0-11
|
||||||
- Fix KeyError: 'console_scripts'
|
- Fix KeyError: 'console_scripts'
|
||||||
- Fixes: rhbz#2231593
|
- Fixes: rhbz#2231593
|
||||||
|
Loading…
Reference in New Issue
Block a user