Fix tests compatibility with pip >= 21.3

This commit is contained in:
Charalampos Stratakis 2022-07-19 22:11:26 +02:00
parent d44fbcb66f
commit e5a5220978
2 changed files with 31 additions and 1 deletions

View File

@ -28,7 +28,7 @@ There is a limited support for (deprecated) optparse objects, too.
Name: argparse-manpage
Version: 3
Release: 3%{?dist}
Release: 4%{?dist}
Summary: %{sum Python}
BuildArch: noarch
@ -36,6 +36,10 @@ License: ASL 2.0
URL: https://github.com/praiskup/%{name}
Source0: https://github.com/praiskup/%name/releases/download/v%version/%name-%version.tar.gz
# Fix tests compatibility with pip >= 21.3
# Fixed upstream: https://github.com/praiskup/argparse-manpage/pull/60
Patch1: fix-pip-21.3-compat.patch
%if %{with python2}
BuildRequires: python2-setuptools python2-devel
%if %{with check}
@ -87,6 +91,7 @@ Summary: %{sum Python 3}
%prep
%setup -q
%patch1 -p1
%if %{with pyproject}
%generate_buildrequires
@ -167,6 +172,9 @@ PYTHONPATH=%buildroot%python3_sitearch %__python3 -m pytest -vv
%changelog
* Fri Jul 22 2022 Charalampos Stratakis <cstratak@redhat.com> - 3-4
- Fix tests compatibility with pip >= 21.3
* Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

22
fix-pip-21.3-compat.patch Normal file
View File

@ -0,0 +1,22 @@
diff --git a/tests/test_examples.py b/tests/test_examples.py
index 66d2352..7886861 100644
--- a/tests/test_examples.py
+++ b/tests/test_examples.py
@@ -49,8 +49,15 @@ def _rmtree(directory):
def run_pip(args):
environ = os.environ.copy()
environ['PYTHONPATH'] = ':'.join(sys.path)
- subprocess.call([sys.executable, '-m', 'pip'] + args + ["--use-feature=in-tree-build", "."],
- env=environ)
+ from pip import __version__
+
+ pip_version = tuple([int(x) for x in __version__.split('.')[:2]])
+ if pip_version < (21, 3):
+ subprocess.call(
+ [sys.executable, '-m', 'pip'] + args + ["--use-feature=in-tree-build", "."],
+ env=environ)
+ else:
+ subprocess.call([sys.executable, '-m', 'pip'] + args + ["."], env=environ)
def run_setup_py(args):