forked from pool/python-pip
Accepting request 963100 from devel:languages:python
OBS-URL: https://build.opensuse.org/request/show/963100 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pip?expand=0&rev=55
This commit is contained in:
commit
426449ea52
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f3a068a9ff1986747514dd07f0a465a5a498c9f426c3198fa88f8a208c98d6a4
|
||||
size 8723163
|
3
pip-22.0.4-gh.tar.gz
Normal file
3
pip-22.0.4-gh.tar.gz
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a9828528aa21cf87093e9332f94ea65931a51c443216f5d3a8f14451ef4f2bbf
|
||||
size 9325766
|
@ -1,25 +1,42 @@
|
||||
Index: pip-20.2.3/src/pip/_vendor/certifi/core.py
|
||||
===================================================================
|
||||
--- pip-20.2.3.orig/src/pip/_vendor/certifi/core.py
|
||||
+++ pip-20.2.3/src/pip/_vendor/certifi/core.py
|
||||
@@ -5,56 +5,18 @@ certifi.py
|
||||
---
|
||||
src/pip/_vendor/certifi/core.py | 70 ++++------------------------------------
|
||||
tests/unit/test_options.py | 5 ++
|
||||
2 files changed, 13 insertions(+), 62 deletions(-)
|
||||
|
||||
--- a/src/pip/_vendor/certifi/core.py
|
||||
+++ b/src/pip/_vendor/certifi/core.py
|
||||
@@ -5,72 +5,18 @@ certifi.py
|
||||
~~~~~~~~~~
|
||||
|
||||
This module returns the installation location of cacert.pem or its contents.
|
||||
-"""
|
||||
-import os
|
||||
-
|
||||
|
||||
-try:
|
||||
- from importlib.resources import path as get_path, read_text
|
||||
-class _PipPatchedCertificate(Exception):
|
||||
- pass
|
||||
+Patched by openSUSE: return the system bundle
|
||||
+"""
|
||||
|
||||
- _CACERT_CTX = None
|
||||
- _CACERT_PATH = None
|
||||
+def read_text(_module=None, _path=None, encoding="ascii"):
|
||||
+ with open(where(), "r", encoding=encoding) as data:
|
||||
+ return data.read()
|
||||
|
||||
-try:
|
||||
- # Return a certificate file on disk for a standalone pip zipapp running in
|
||||
- # an isolated build environment to use. Passing --cert to the standalone
|
||||
- # pip does not work since requests calls where() unconditionally on import.
|
||||
- _PIP_STANDALONE_CERT = os.environ.get("_PIP_STANDALONE_CERT")
|
||||
- if _PIP_STANDALONE_CERT:
|
||||
- def where():
|
||||
- return _PIP_STANDALONE_CERT
|
||||
- raise _PipPatchedCertificate()
|
||||
-
|
||||
- from importlib.resources import path as get_path, read_text
|
||||
-
|
||||
- _CACERT_CTX = None
|
||||
- _CACERT_PATH = None
|
||||
-
|
||||
- def where():
|
||||
- # This is slightly terrible, but we want to delay extracting the file
|
||||
- # in cases where we're inside of a zipimport situation until someone
|
||||
@ -44,6 +61,8 @@ Index: pip-20.2.3/src/pip/_vendor/certifi/core.py
|
||||
-
|
||||
- return _CACERT_PATH
|
||||
-
|
||||
-except _PipPatchedCertificate:
|
||||
- pass
|
||||
-
|
||||
-except ImportError:
|
||||
- # This fallback will work for Python versions prior to 3.7 that lack the
|
||||
@ -67,3 +86,29 @@ Index: pip-20.2.3/src/pip/_vendor/certifi/core.py
|
||||
def contents():
|
||||
- return read_text("certifi", "cacert.pem", encoding="ascii")
|
||||
+ return read_text(encoding="ascii")
|
||||
--- a/tests/unit/test_options.py
|
||||
+++ b/tests/unit/test_options.py
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
+import os.path
|
||||
from contextlib import contextmanager
|
||||
from optparse import Values
|
||||
from tempfile import NamedTemporaryFile
|
||||
@@ -11,6 +12,7 @@ from pip._internal.cli.main import main
|
||||
from pip._internal.commands import create_command
|
||||
from pip._internal.commands.configuration import ConfigurationCommand
|
||||
from pip._internal.exceptions import PipError
|
||||
+from pip._vendor.certifi import where
|
||||
from tests.lib.options_helpers import AddFakeCommandMixin
|
||||
from tests.lib.path import Path
|
||||
|
||||
@@ -620,6 +622,9 @@ class TestOptionsConfigFiles:
|
||||
else:
|
||||
assert expect == cmd._determine_file(options, need_value=False)
|
||||
|
||||
+ def test_certificates(self):
|
||||
+ assert os.path.exists(where())
|
||||
+
|
||||
|
||||
class TestOptionsExpandUser(AddFakeCommandMixin):
|
||||
def test_cache_dir(self) -> None:
|
||||
|
@ -1,3 +1,162 @@
|
||||
-------------------------------------------------------------------
|
||||
Sat Mar 19 17:14:58 UTC 2022 - Ben Greiner <code@bnavigator.de>
|
||||
|
||||
- Avoid cycle: BuildRequire ca-certificates only in tests
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 18 09:32:29 UTC 2022 - Ben Greiner <code@bnavigator.de>
|
||||
|
||||
- Update requirements: v22 is not compatible with Python 3.6 and
|
||||
thus not suitable for SLE/Leap 15.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Mar 17 10:28:24 UTC 2022 - Matej Cepl <mcepl@suse.com>
|
||||
|
||||
- Update to 22.0.4:
|
||||
- Drop the doctype check, that presented a warning for index
|
||||
pages that use non-compliant HTML 5.
|
||||
- Update to 22.0.3:
|
||||
- Print the exception via rich.traceback, when running with
|
||||
--debug.
|
||||
- Only calculate topological installation order, for packages
|
||||
that are going to be installed/upgraded.
|
||||
- This fixes an AssertionError that occured when determining
|
||||
installation order, for a very specific combination of
|
||||
upgrading-already-installed-package + change of dependencies
|
||||
+ fetching some packages from a package index. This
|
||||
combination was especially common in Read the Docs'
|
||||
builds.
|
||||
- Use html.parser by default, instead of falling back
|
||||
to html5lib when --use-deprecated=html5lib is not
|
||||
passed.
|
||||
- Clarify that using per-requirement overrides disables the
|
||||
usage of wheels.
|
||||
- Update to 22.0.2:
|
||||
- Instead of failing on index pages that use non-compliant
|
||||
HTML 5, print a deprecation warning and fall back to
|
||||
html5lib-based parsing for now. This simplifies the migration
|
||||
for non-compliant index pages, by letting such indexes
|
||||
function with a warning.
|
||||
- Update to 22.0.1:
|
||||
- Accept lowercase <!doctype html> on index pages.
|
||||
- Properly handle links parsed by html5lib, when using
|
||||
--use-deprecated=html5lib.
|
||||
- Update to 22.0:
|
||||
- Completely replace :pypi:`tox` in our development workflow,
|
||||
with :pypi:`nox`.
|
||||
- Deprecate alternative progress bar styles, leaving only on
|
||||
and off as available choices.
|
||||
- Drop support for Python 3.6.
|
||||
- Disable location mismatch warnings on Python versions prior
|
||||
to 3.10.
|
||||
- These warnings were helping identify potential issues as part
|
||||
of the sysconfig -> distutils transition, and we no longer
|
||||
need to rely on reports from older Python versions for
|
||||
information on the transition.
|
||||
- Changed PackageFinder to parse HTML documents using the
|
||||
stdlib :class:`html.parser.HTMLParser` class instead of the
|
||||
html5lib package.
|
||||
- For now, the deprecated html5lib code remains and can be used
|
||||
with the --use-deprecated=html5lib command line option.
|
||||
However, it will be removed in a future pip release.
|
||||
- Utilise rich for presenting pip's default download progress
|
||||
bar.
|
||||
- Present a better error message when an invalid wheel file is
|
||||
encountered, providing more context where the invalid wheel
|
||||
file is.
|
||||
- Documents the --require-virtualenv flag for pip install.
|
||||
- pip install <tab> autocompletes paths.
|
||||
- Allow Python distributors to opt-out from or opt-in to the
|
||||
sysconfig installation scheme backend by setting
|
||||
sysconfig._PIP_USE_SYSCONFIG to True or False.
|
||||
- Make it possible to deselect tests requiring cryptography
|
||||
package on systems where it cannot be installed.
|
||||
- Start using Rich for presenting error messages in
|
||||
a consistent format.
|
||||
- Improve presentation of errors from subprocesses.
|
||||
- Forward pip's verbosity configuration to VCS tools to control
|
||||
their output accordingly.
|
||||
- Optimize installation order calculation to improve
|
||||
performance when installing requirements that form a complex
|
||||
dependency graph with a large amount of edges.
|
||||
- When a package is requested by the user for upgrade,
|
||||
correctly identify that the extra-ed variant of that same
|
||||
package depended by another user-requested package is
|
||||
requesting the same package, and upgrade it accordingly.
|
||||
- Prevent pip from installing yanked releases unless explicitly
|
||||
pinned via the == or === operators.
|
||||
- Stop backtracking on build failures, by instead surfacing
|
||||
them to the user and aborting immediately. This behaviour
|
||||
provides more immediate feedback when a package cannot be
|
||||
built due to missing build dependencies or platform
|
||||
incompatibility.
|
||||
- Silence Value for <location> does not match warning caused by
|
||||
an erroneous patch in Slackware-distributed Python 3.9.
|
||||
- Fix an issue where pip did not consider dependencies with and
|
||||
without extras to be equal
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Nov 7 17:07:30 UTC 2021 - Dirk Müller <dmueller@suse.com>
|
||||
|
||||
- update to 21.3.1:
|
||||
* Always refuse installing or building projects that have no ``pyproject.toml`` nor
|
||||
``setup.py``.
|
||||
* Tweak running-as-root detection, to check ``os.getuid`` if it exists, on
|
||||
Unix-y and non-Linux/non-MacOS machines.
|
||||
* When installing projects with a ``pyproject.toml`` in editable mode, and the build
|
||||
backend does not support :pep:`660`, prepare metadata using
|
||||
``prepare_metadata_for_build_wheel`` instead of ``setup.py egg_info``. Also, refuse
|
||||
installing projects that only have a ``setup.cfg`` and no ``setup.py`` nor
|
||||
``pyproject.toml``. These restore the pre-21.3 behaviour.
|
||||
* Restore compatibility of where configuration files are loaded from on MacOS
|
||||
* Upgrade pep517 to 0.12.0
|
||||
* Improve deprecation warning regarding the copying of source trees when
|
||||
installing from a local directory.
|
||||
* Suppress location mismatch warnings when pip is invoked from a Python source
|
||||
tree, so ``ensurepip`` does not emit warnings on CPython ``make install``.
|
||||
* On Python 3.10 or later, the installation scheme backend has been changed to use
|
||||
``sysconfig``. This is to anticipate the deprecation of ``distutils`` in Python
|
||||
3.10, and its scheduled removal in 3.12. For compatibility considerations, pip
|
||||
installations running on Python 3.9 or lower will continue to use ``distutils``.
|
||||
* Remove the ``--build-dir`` option and aliases, one last time.
|
||||
* In-tree builds are now the default. ``--use-feature=in-tree-build`` is now
|
||||
ignored. ``--use-deprecated=out-of-tree-build`` may be used temporarily to ease
|
||||
the transition.
|
||||
* Un-deprecate source distribution re-installation behaviour.
|
||||
* Replace vendored appdirs with platformdirs.
|
||||
* Support `PEP 610 <https://www.python.org/dev/peps/pep-0610/>`_ to detect
|
||||
editable installs in ``pip freeze`` and ``pip list``. The ``pip list`` column output
|
||||
has a new ``Editable project location`` column, and the JSON output has a new
|
||||
``editable_project_location`` field.
|
||||
* ``pip freeze`` will now always fallback to reporting the editable project
|
||||
location when it encounters a VCS error while analyzing an editable
|
||||
requirement. Before, it sometimes reported the requirement as non-editable.
|
||||
* ``pip show`` now sorts ``Requires`` and ``Required-By`` alphabetically.
|
||||
* Do not raise error when there are no files to remove with ``pip cache purge/remove``.
|
||||
Instead log a warning and continue (to log that we removed 0 files).
|
||||
* When backtracking during dependency resolution, prefer the dependencies
|
||||
which are involved in the most recent conflict. This can significantly
|
||||
reduce the amount of backtracking required.
|
||||
* Cache requirement objects, to improve performance reducing reparses of requirement strings.
|
||||
* Support editable installs for projects that have a ``pyproject.toml`` and use a
|
||||
build backend that supports :pep:`660`.
|
||||
* When a revision is specified in a Git URL, use git's partial clone feature
|
||||
to speed up source retrieval.
|
||||
* Add a ``--debug`` flag, to enable a mode that doesn't log errors and
|
||||
propagates them to the top level instead. This is primarily to aid with
|
||||
debugging pip's crashes.
|
||||
* If a host is explicitly specified as trusted by the user (via the
|
||||
--trusted-host option), cache HTTP responses from it in addition to HTTPS
|
||||
ones.
|
||||
* Present a better error message, when a ``file:`` URL is not found.
|
||||
* Fix the auth credential cache to allow for the case in which
|
||||
the index url contains the username, but the password comes
|
||||
from an external source, such as keyring.
|
||||
* Fix double unescape of HTML ``data-requires-python`` and ``data-yanked`` attributes.
|
||||
* New resolver: Fixes depth ordering of packages during resolution, e.g. a
|
||||
dependency 2 levels deep will be ordered before a dependecy 3 levels deep.
|
||||
- drop remove_mock.patch (upstream)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 8 16:07:38 UTC 2021 - Stefan Schubert <schubi@suse.de>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-pip
|
||||
# spec file
|
||||
#
|
||||
# Copyright (c) 2021 SUSE LLC
|
||||
# Copyright (c) 2022 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -22,7 +22,7 @@
|
||||
%bcond_with libalternatives
|
||||
%endif
|
||||
|
||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||
%{?!python_module:%define python_module() python3-%{**}}
|
||||
%global flavor @BUILD_FLAVOR@%{nil}
|
||||
%if "%{flavor}" == "test"
|
||||
%define psuffix -test
|
||||
@ -32,14 +32,16 @@
|
||||
%if "%{flavor}" == "wheel"
|
||||
%define psuffix -wheel
|
||||
%bcond_without wheel
|
||||
%bcond_with test
|
||||
%else
|
||||
%define psuffix %{nil}
|
||||
%bcond_with test
|
||||
%bcond_with wheel
|
||||
%endif
|
||||
%endif
|
||||
%global skip_python2 1
|
||||
Name: python-pip%{psuffix}
|
||||
Version: 20.2.4
|
||||
Version: 22.0.4
|
||||
Release: 0
|
||||
Summary: A Python package management system
|
||||
License: MIT
|
||||
@ -48,9 +50,7 @@ URL: http://www.pip-installer.org
|
||||
Source: https://github.com/pypa/pip/archive/%{version}.tar.gz#/pip-%{version}-gh.tar.gz
|
||||
# PATCH-FIX-OPENSUSE pip-shipped-requests-cabundle.patch -- adapted patch from python-certifi package
|
||||
Patch0: pip-shipped-requests-cabundle.patch
|
||||
# PATCH-FIX-UPSTREAM remove_mock.patch gh#pypa/pip#9266 mcepl@suse.com
|
||||
# remove dependency on the external module mock
|
||||
Patch1: remove_mock.patch
|
||||
BuildRequires: %{python_module base >= 3.7}
|
||||
BuildRequires: %{python_module setuptools >= 40.8.0}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros >= 20210929
|
||||
|
@ -1,601 +0,0 @@
|
||||
---
|
||||
tests/functional/test_help.py | 5 +
|
||||
tests/lib/server.py | 5 +
|
||||
tests/unit/resolution_resolvelib/test_resolver.py | 5 +
|
||||
tests/unit/test_base_command.py | 5 +
|
||||
tests/unit/test_check.py | 5 +
|
||||
tests/unit/test_collector.py | 66 +++++++++++-----------
|
||||
tests/unit/test_command_install.py | 5 +
|
||||
tests/unit/test_commands.py | 5 +
|
||||
tests/unit/test_configuration.py | 5 +
|
||||
tests/unit/test_direct_url_helpers.py | 5 +
|
||||
tests/unit/test_finder.py | 5 +
|
||||
tests/unit/test_locations.py | 5 +
|
||||
tests/unit/test_logging.py | 5 +
|
||||
tests/unit/test_network_cache.py | 5 +
|
||||
tests/unit/test_operations_prepare.py | 5 +
|
||||
tests/unit/test_req.py | 5 +
|
||||
tests/unit/test_req_file.py | 5 +
|
||||
tests/unit/test_req_uninstall.py | 5 +
|
||||
tests/unit/test_resolution_legacy_resolver.py | 5 +
|
||||
tests/unit/test_target_python.py | 5 +
|
||||
tests/unit/test_utils.py | 5 +
|
||||
tests/unit/test_utils_compatibility_tags.py | 5 +
|
||||
tests/unit/test_vcs.py | 5 +
|
||||
tests/unit/test_wheel.py | 5 +
|
||||
tests/unit/test_wheel_builder.py | 5 +
|
||||
25 files changed, 130 insertions(+), 56 deletions(-)
|
||||
|
||||
--- a/tests/lib/server.py
|
||||
+++ b/tests/lib/server.py
|
||||
@@ -5,7 +5,10 @@ import threading
|
||||
from contextlib import contextmanager
|
||||
from textwrap import dedent
|
||||
|
||||
-from mock import Mock
|
||||
+try:
|
||||
+ from unittest.mock import Mock
|
||||
+except ImportError:
|
||||
+ from mock import Mock
|
||||
from pip._vendor.contextlib2 import nullcontext
|
||||
from werkzeug.serving import WSGIRequestHandler
|
||||
from werkzeug.serving import make_server as _make_server
|
||||
--- a/tests/unit/test_base_command.py
|
||||
+++ b/tests/unit/test_base_command.py
|
||||
@@ -3,7 +3,10 @@ import os
|
||||
import time
|
||||
|
||||
import pytest
|
||||
-from mock import Mock, patch
|
||||
+try:
|
||||
+ from unittest.mock import Mock, patch
|
||||
+except ImportError:
|
||||
+ from mock import Mock, patch
|
||||
|
||||
from pip._internal.cli.base_command import Command
|
||||
from pip._internal.cli.status_codes import SUCCESS
|
||||
--- a/tests/unit/test_commands.py
|
||||
+++ b/tests/unit/test_commands.py
|
||||
@@ -1,5 +1,8 @@
|
||||
import pytest
|
||||
-from mock import patch
|
||||
+try:
|
||||
+ from unittest.mock import patch
|
||||
+except ImportError:
|
||||
+ from mock import patch
|
||||
|
||||
from pip._internal.cli.req_command import (
|
||||
IndexGroupCommand,
|
||||
--- a/tests/unit/test_network_cache.py
|
||||
+++ b/tests/unit/test_network_cache.py
|
||||
@@ -1,7 +1,10 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
-from mock import Mock
|
||||
+try:
|
||||
+ from unittest.mock import Mock
|
||||
+except ImportError:
|
||||
+ from mock import Mock
|
||||
from pip._vendor.cachecontrol.caches import FileCache
|
||||
|
||||
from pip._internal.network.cache import SafeFileCache
|
||||
--- a/tests/unit/test_req_file.py
|
||||
+++ b/tests/unit/test_req_file.py
|
||||
@@ -5,7 +5,10 @@ import subprocess
|
||||
import textwrap
|
||||
|
||||
import pytest
|
||||
-from mock import patch
|
||||
+try:
|
||||
+ from unittest.mock import patch
|
||||
+except ImportError:
|
||||
+ from mock import patch
|
||||
from pip._vendor.six import PY2
|
||||
from pretend import stub
|
||||
|
||||
--- a/tests/unit/test_resolution_legacy_resolver.py
|
||||
+++ b/tests/unit/test_resolution_legacy_resolver.py
|
||||
@@ -1,6 +1,9 @@
|
||||
import logging
|
||||
|
||||
-import mock
|
||||
+try:
|
||||
+ from unittest.mock import Mock
|
||||
+except ImportError:
|
||||
+ from mock import Mock
|
||||
import pytest
|
||||
from pip._vendor import pkg_resources
|
||||
|
||||
@@ -189,7 +192,7 @@ class TestYankedWarning(object):
|
||||
|
||||
return Resolver(
|
||||
finder=finder,
|
||||
- preparer=mock.Mock(), # Not used.
|
||||
+ preparer=Mock(), # Not used.
|
||||
make_install_req=install_req_from_line,
|
||||
wheel_cache=None,
|
||||
use_user_site=False,
|
||||
--- a/tests/unit/test_target_python.py
|
||||
+++ b/tests/unit/test_target_python.py
|
||||
@@ -1,5 +1,8 @@
|
||||
import pytest
|
||||
-from mock import patch
|
||||
+try:
|
||||
+ from unittest.mock import patch
|
||||
+except ImportError:
|
||||
+ from mock import patch
|
||||
|
||||
from pip._internal.models.target_python import TargetPython
|
||||
from tests.lib import CURRENT_PY_VERSION_INFO, pyversion
|
||||
--- a/tests/unit/test_utils.py
|
||||
+++ b/tests/unit/test_utils.py
|
||||
@@ -14,7 +14,10 @@ import time
|
||||
from io import BytesIO
|
||||
|
||||
import pytest
|
||||
-from mock import Mock, patch
|
||||
+try:
|
||||
+ from unittest.mock import Mock, patch
|
||||
+except ImportError:
|
||||
+ from mock import Mock, patch
|
||||
|
||||
from pip._internal.exceptions import (
|
||||
HashMismatch,
|
||||
--- a/tests/unit/test_utils_compatibility_tags.py
|
||||
+++ b/tests/unit/test_utils_compatibility_tags.py
|
||||
@@ -1,7 +1,10 @@
|
||||
import sysconfig
|
||||
|
||||
import pytest
|
||||
-from mock import patch
|
||||
+try:
|
||||
+ from unittest.mock import patch
|
||||
+except ImportError:
|
||||
+ from mock import patch
|
||||
|
||||
from pip._internal.utils import compatibility_tags
|
||||
|
||||
--- a/tests/unit/test_vcs.py
|
||||
+++ b/tests/unit/test_vcs.py
|
||||
@@ -2,7 +2,10 @@ import os
|
||||
from unittest import TestCase
|
||||
|
||||
import pytest
|
||||
-from mock import patch
|
||||
+try:
|
||||
+ from unittest.mock import patch
|
||||
+except ImportError:
|
||||
+ from mock import patch
|
||||
from pip._vendor.packaging.version import parse as parse_version
|
||||
|
||||
from pip._internal.exceptions import BadCommand, InstallationError
|
||||
--- a/tests/unit/test_wheel.py
|
||||
+++ b/tests/unit/test_wheel.py
|
||||
@@ -8,7 +8,10 @@ import textwrap
|
||||
from email import message_from_string
|
||||
|
||||
import pytest
|
||||
-from mock import patch
|
||||
+try:
|
||||
+ from unittest.mock import patch
|
||||
+except ImportError:
|
||||
+ from mock import patch
|
||||
from pip._vendor.packaging.requirements import Requirement
|
||||
|
||||
from pip._internal.exceptions import InstallationError
|
||||
--- a/tests/unit/test_wheel_builder.py
|
||||
+++ b/tests/unit/test_wheel_builder.py
|
||||
@@ -1,7 +1,10 @@
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
-from mock import patch
|
||||
+try:
|
||||
+ from unittest.mock import patch
|
||||
+except ImportError:
|
||||
+ from mock import patch
|
||||
|
||||
from pip._internal import wheel_builder
|
||||
from pip._internal.models.link import Link
|
||||
--- a/tests/functional/test_help.py
|
||||
+++ b/tests/functional/test_help.py
|
||||
@@ -1,5 +1,8 @@
|
||||
import pytest
|
||||
-from mock import Mock
|
||||
+try:
|
||||
+ from unittest.mock import Mock
|
||||
+except ImportError:
|
||||
+ from mock import Mock
|
||||
|
||||
from pip._internal.cli.status_codes import ERROR, SUCCESS
|
||||
from pip._internal.commands import commands_dict, create_command
|
||||
--- a/tests/unit/resolution_resolvelib/test_resolver.py
|
||||
+++ b/tests/unit/resolution_resolvelib/test_resolver.py
|
||||
@@ -1,4 +1,7 @@
|
||||
-import mock
|
||||
+try:
|
||||
+ from unittest.mock import Mock
|
||||
+except ImportError:
|
||||
+ from mock import Mock
|
||||
import pytest
|
||||
from pip._vendor.packaging.utils import canonicalize_name
|
||||
from pip._vendor.resolvelib.resolvers import Result
|
||||
@@ -18,7 +21,7 @@ def resolver(preparer, finder):
|
||||
preparer=preparer,
|
||||
finder=finder,
|
||||
wheel_cache=None,
|
||||
- make_install_req=mock.Mock(),
|
||||
+ make_install_req=Mock(),
|
||||
use_user_site="not-used",
|
||||
ignore_dependencies="not-used",
|
||||
ignore_installed="not-used",
|
||||
--- a/tests/unit/test_check.py
|
||||
+++ b/tests/unit/test_check.py
|
||||
@@ -1,7 +1,10 @@
|
||||
"""Unit Tests for pip's dependency checking logic
|
||||
"""
|
||||
|
||||
-import mock
|
||||
+try:
|
||||
+ from unittest.mock import MagicMock
|
||||
+except ImportError:
|
||||
+ from mock import MagicMock
|
||||
|
||||
from pip._internal.operations import check
|
||||
|
||||
@@ -9,7 +12,7 @@ from pip._internal.operations import che
|
||||
class TestInstalledDistributionsCall(object):
|
||||
|
||||
def test_passes_correct_default_kwargs(self, monkeypatch):
|
||||
- my_mock = mock.MagicMock(return_value=[])
|
||||
+ my_mock = MagicMock(return_value=[])
|
||||
monkeypatch.setattr(check, "get_installed_distributions", my_mock)
|
||||
|
||||
check.create_package_set_from_installed()
|
||||
@@ -17,7 +20,7 @@ class TestInstalledDistributionsCall(obj
|
||||
my_mock.assert_called_with(local_only=False, skip=())
|
||||
|
||||
def test_passes_any_given_kwargs(self, monkeypatch):
|
||||
- my_mock = mock.MagicMock(return_value=[])
|
||||
+ my_mock = MagicMock(return_value=[])
|
||||
monkeypatch.setattr(check, "get_installed_distributions", my_mock)
|
||||
|
||||
obj = object()
|
||||
--- a/tests/unit/test_collector.py
|
||||
+++ b/tests/unit/test_collector.py
|
||||
@@ -4,10 +4,12 @@ import re
|
||||
import uuid
|
||||
from textwrap import dedent
|
||||
|
||||
-import mock
|
||||
+try:
|
||||
+ from unittest.mock import Mock, call, patch
|
||||
+except ImportError:
|
||||
+ from mock import Mock, call, patch
|
||||
import pretend
|
||||
import pytest
|
||||
-from mock import Mock, patch
|
||||
from pip._vendor import html5lib, requests
|
||||
from pip._vendor.six.moves.urllib import request as urllib_request
|
||||
|
||||
@@ -46,7 +48,7 @@ def test_get_html_response_archive_to_na
|
||||
does not allow "poking" without getting data.
|
||||
"""
|
||||
with pytest.raises(_NotHTTP):
|
||||
- _get_html_response(url, session=mock.Mock(PipSession))
|
||||
+ _get_html_response(url, session=Mock(PipSession))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -56,15 +58,15 @@ def test_get_html_response_archive_to_na
|
||||
("https://pypi.org/pip-18.0.tar.gz", "application/gzip"),
|
||||
],
|
||||
)
|
||||
-@mock.patch("pip._internal.index.collector.raise_for_status")
|
||||
+@patch("pip._internal.index.collector.raise_for_status")
|
||||
def test_get_html_response_archive_to_http_scheme(mock_raise_for_status, url,
|
||||
content_type):
|
||||
"""
|
||||
`_get_html_response()` should send a HEAD request on an archive-like URL
|
||||
if the scheme supports it, and raise `_NotHTML` if the response isn't HTML.
|
||||
"""
|
||||
- session = mock.Mock(PipSession)
|
||||
- session.head.return_value = mock.Mock(**{
|
||||
+ session = Mock(PipSession)
|
||||
+ session.head.return_value = Mock(**{
|
||||
"request.method": "HEAD",
|
||||
"headers": {"Content-Type": content_type},
|
||||
})
|
||||
@@ -73,7 +75,7 @@ def test_get_html_response_archive_to_ht
|
||||
_get_html_response(url, session=session)
|
||||
|
||||
session.assert_has_calls([
|
||||
- mock.call.head(url, allow_redirects=True),
|
||||
+ call.head(url, allow_redirects=True),
|
||||
])
|
||||
mock_raise_for_status.assert_called_once_with(session.head.return_value)
|
||||
assert ctx.value.args == (content_type, "HEAD")
|
||||
@@ -93,7 +95,7 @@ def test_get_html_page_invalid_content_t
|
||||
caplog.set_level(logging.WARNING)
|
||||
link = Link(url)
|
||||
|
||||
- session = mock.Mock(PipSession)
|
||||
+ session = Mock(PipSession)
|
||||
|
||||
assert _get_html_page(link, session=session) is None
|
||||
assert ('pip._internal.index.collector',
|
||||
@@ -111,7 +113,7 @@ def test_get_html_page_invalid_content_t
|
||||
"https://pypi.org/pip-18.0.tar.gz",
|
||||
],
|
||||
)
|
||||
-@mock.patch("pip._internal.index.collector.raise_for_status")
|
||||
+@patch("pip._internal.index.collector.raise_for_status")
|
||||
def test_get_html_response_archive_to_http_scheme_is_html(
|
||||
mock_raise_for_status, url
|
||||
):
|
||||
@@ -119,25 +121,25 @@ def test_get_html_response_archive_to_ht
|
||||
`_get_html_response()` should work with archive-like URLs if the HEAD
|
||||
request is responded with text/html.
|
||||
"""
|
||||
- session = mock.Mock(PipSession)
|
||||
- session.head.return_value = mock.Mock(**{
|
||||
+ session = Mock(PipSession)
|
||||
+ session.head.return_value = Mock(**{
|
||||
"request.method": "HEAD",
|
||||
"headers": {"Content-Type": "text/html"},
|
||||
})
|
||||
- session.get.return_value = mock.Mock(headers={"Content-Type": "text/html"})
|
||||
+ session.get.return_value = Mock(headers={"Content-Type": "text/html"})
|
||||
|
||||
resp = _get_html_response(url, session=session)
|
||||
|
||||
assert resp is not None
|
||||
assert session.mock_calls == [
|
||||
- mock.call.head(url, allow_redirects=True),
|
||||
- mock.call.get(url, headers={
|
||||
+ call.head(url, allow_redirects=True),
|
||||
+ call.get(url, headers={
|
||||
"Accept": "text/html", "Cache-Control": "max-age=0",
|
||||
}),
|
||||
]
|
||||
assert mock_raise_for_status.mock_calls == [
|
||||
- mock.call(session.head.return_value),
|
||||
- mock.call(resp)
|
||||
+ call(session.head.return_value),
|
||||
+ call(resp)
|
||||
]
|
||||
|
||||
|
||||
@@ -149,16 +151,16 @@ def test_get_html_response_archive_to_ht
|
||||
"https://python.org/sitemap.xml",
|
||||
],
|
||||
)
|
||||
-@mock.patch("pip._internal.index.collector.raise_for_status")
|
||||
+@patch("pip._internal.index.collector.raise_for_status")
|
||||
def test_get_html_response_no_head(mock_raise_for_status, url):
|
||||
"""
|
||||
`_get_html_response()` shouldn't send a HEAD request if the URL does not
|
||||
look like an archive, only the GET request that retrieves data.
|
||||
"""
|
||||
- session = mock.Mock(PipSession)
|
||||
+ session = Mock(PipSession)
|
||||
|
||||
# Mock the headers dict to ensure it is accessed.
|
||||
- session.get.return_value = mock.Mock(headers=mock.Mock(**{
|
||||
+ session.get.return_value = Mock(headers=Mock(**{
|
||||
"get.return_value": "text/html",
|
||||
}))
|
||||
|
||||
@@ -167,25 +169,25 @@ def test_get_html_response_no_head(mock_
|
||||
assert resp is not None
|
||||
assert session.head.call_count == 0
|
||||
assert session.get.mock_calls == [
|
||||
- mock.call(url, headers={
|
||||
+ call(url, headers={
|
||||
"Accept": "text/html", "Cache-Control": "max-age=0",
|
||||
}),
|
||||
- mock.call().headers.get("Content-Type", ""),
|
||||
+ call().headers.get("Content-Type", ""),
|
||||
]
|
||||
mock_raise_for_status.assert_called_once_with(resp)
|
||||
|
||||
|
||||
-@mock.patch("pip._internal.index.collector.raise_for_status")
|
||||
+@patch("pip._internal.index.collector.raise_for_status")
|
||||
def test_get_html_response_dont_log_clear_text_password(mock_raise_for_status,
|
||||
caplog):
|
||||
"""
|
||||
`_get_html_response()` should redact the password from the index URL
|
||||
in its DEBUG log message.
|
||||
"""
|
||||
- session = mock.Mock(PipSession)
|
||||
+ session = Mock(PipSession)
|
||||
|
||||
# Mock the headers dict to ensure it is accessed.
|
||||
- session.get.return_value = mock.Mock(headers=mock.Mock(**{
|
||||
+ session.get.return_value = Mock(headers=Mock(**{
|
||||
"get.return_value": "text/html",
|
||||
}))
|
||||
|
||||
@@ -451,7 +453,7 @@ def test_parse_links_caches_same_page_by
|
||||
assert 'pkg2' in parsed_links_3[0].url
|
||||
|
||||
|
||||
-@mock.patch("pip._internal.index.collector.raise_for_status")
|
||||
+@patch("pip._internal.index.collector.raise_for_status")
|
||||
def test_request_http_error(mock_raise_for_status, caplog):
|
||||
caplog.set_level(logging.DEBUG)
|
||||
link = Link('http://localhost')
|
||||
@@ -504,7 +506,7 @@ def test_get_html_page_invalid_scheme(ca
|
||||
Only file:, http:, https:, and ftp: are allowed.
|
||||
"""
|
||||
with caplog.at_level(logging.WARNING):
|
||||
- page = _get_html_page(Link(url), session=mock.Mock(PipSession))
|
||||
+ page = _get_html_page(Link(url), session=Mock(PipSession))
|
||||
|
||||
assert page is None
|
||||
assert caplog.record_tuples == [
|
||||
@@ -524,7 +526,7 @@ def test_get_html_page_invalid_scheme(ca
|
||||
"application/json",
|
||||
],
|
||||
)
|
||||
-@mock.patch("pip._internal.index.collector.raise_for_status")
|
||||
+@patch("pip._internal.index.collector.raise_for_status")
|
||||
def test_get_html_page_invalid_content_type(mock_raise_for_status,
|
||||
caplog, content_type):
|
||||
"""`_get_html_page()` should warn if an invalid content-type is given.
|
||||
@@ -534,8 +536,8 @@ def test_get_html_page_invalid_content_t
|
||||
url = 'https://pypi.org/simple/pip'
|
||||
link = Link(url)
|
||||
|
||||
- session = mock.Mock(PipSession)
|
||||
- session.get.return_value = mock.Mock(**{
|
||||
+ session = Mock(PipSession)
|
||||
+ session.get.return_value = Mock(**{
|
||||
"request.method": "GET",
|
||||
"headers": {"Content-Type": content_type},
|
||||
})
|
||||
@@ -573,14 +575,14 @@ def test_get_html_page_directory_append_
|
||||
)
|
||||
expected_url = "{}/index.html".format(dir_url.rstrip("/"))
|
||||
|
||||
- session = mock.Mock(PipSession)
|
||||
+ session = Mock(PipSession)
|
||||
fake_response = make_fake_html_response(expected_url)
|
||||
- mock_func = mock.patch("pip._internal.index.collector._get_html_response")
|
||||
+ mock_func = patch("pip._internal.index.collector._get_html_response")
|
||||
with mock_func as mock_func:
|
||||
mock_func.return_value = fake_response
|
||||
actual = _get_html_page(Link(dir_url), session=session)
|
||||
assert mock_func.mock_calls == [
|
||||
- mock.call(expected_url, session=session),
|
||||
+ call(expected_url, session=session),
|
||||
], 'actual calls: {}'.format(mock_func.mock_calls)
|
||||
|
||||
assert actual.content == fake_response.content
|
||||
--- a/tests/unit/test_command_install.py
|
||||
+++ b/tests/unit/test_command_install.py
|
||||
@@ -1,7 +1,10 @@
|
||||
import errno
|
||||
|
||||
import pytest
|
||||
-from mock import patch
|
||||
+try:
|
||||
+ from unittest.mock import patch
|
||||
+except ImportError:
|
||||
+ from mock import patch
|
||||
from pip._vendor.packaging.requirements import Requirement
|
||||
|
||||
from pip._internal.commands.install import (
|
||||
--- a/tests/unit/test_configuration.py
|
||||
+++ b/tests/unit/test_configuration.py
|
||||
@@ -4,7 +4,10 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
-from mock import MagicMock
|
||||
+try:
|
||||
+ from unittest.mock import MagicMock
|
||||
+except ImportError:
|
||||
+ from mock import MagicMock
|
||||
|
||||
from pip._internal.configuration import get_configuration_files, kinds
|
||||
from pip._internal.exceptions import ConfigurationError
|
||||
--- a/tests/unit/test_direct_url_helpers.py
|
||||
+++ b/tests/unit/test_direct_url_helpers.py
|
||||
@@ -1,6 +1,9 @@
|
||||
from functools import partial
|
||||
|
||||
-from mock import MagicMock, patch
|
||||
+try:
|
||||
+ from unittest.mock import MagicMock, patch
|
||||
+except ImportError:
|
||||
+ from mock import MagicMock, patch
|
||||
|
||||
from pip._internal.models.direct_url import (
|
||||
DIRECT_URL_METADATA_NAME,
|
||||
--- a/tests/unit/test_finder.py
|
||||
+++ b/tests/unit/test_finder.py
|
||||
@@ -2,7 +2,10 @@ import logging
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
-from mock import Mock, patch
|
||||
+try:
|
||||
+ from unittest.mock import Mock, patch
|
||||
+except ImportError:
|
||||
+ from mock import Mock, patch
|
||||
from pip._vendor.packaging.specifiers import SpecifierSet
|
||||
from pip._vendor.packaging.tags import Tag
|
||||
from pkg_resources import parse_version
|
||||
--- a/tests/unit/test_locations.py
|
||||
+++ b/tests/unit/test_locations.py
|
||||
@@ -9,7 +9,10 @@ import sys
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
-from mock import Mock
|
||||
+try:
|
||||
+ from unittest.mock import Mock
|
||||
+except ImportError:
|
||||
+ from mock import Mock
|
||||
|
||||
from pip._internal.locations import distutils_scheme
|
||||
|
||||
--- a/tests/unit/test_logging.py
|
||||
+++ b/tests/unit/test_logging.py
|
||||
@@ -5,7 +5,10 @@ import time
|
||||
from threading import Thread
|
||||
|
||||
import pytest
|
||||
-from mock import patch
|
||||
+try:
|
||||
+ from unittest.mock import patch
|
||||
+except ImportError:
|
||||
+ from mock import patch
|
||||
from pip._vendor.six import PY2
|
||||
|
||||
from pip._internal.utils.logging import (
|
||||
--- a/tests/unit/test_operations_prepare.py
|
||||
+++ b/tests/unit/test_operations_prepare.py
|
||||
@@ -4,7 +4,10 @@ from shutil import rmtree
|
||||
from tempfile import mkdtemp
|
||||
|
||||
import pytest
|
||||
-from mock import Mock, patch
|
||||
+try:
|
||||
+ from unittest.mock import Mock, patch
|
||||
+except ImportError:
|
||||
+ from mock import Mock, patch
|
||||
|
||||
from pip._internal.exceptions import HashMismatch
|
||||
from pip._internal.models.link import Link
|
||||
--- a/tests/unit/test_req.py
|
||||
+++ b/tests/unit/test_req.py
|
||||
@@ -6,7 +6,10 @@ import tempfile
|
||||
from functools import partial
|
||||
|
||||
import pytest
|
||||
-from mock import patch
|
||||
+try:
|
||||
+ from unittest.mock import patch
|
||||
+except ImportError:
|
||||
+ from mock import patch
|
||||
from pip._vendor import pkg_resources
|
||||
from pip._vendor.packaging.markers import Marker
|
||||
from pip._vendor.packaging.requirements import Requirement
|
||||
--- a/tests/unit/test_req_uninstall.py
|
||||
+++ b/tests/unit/test_req_uninstall.py
|
||||
@@ -2,7 +2,10 @@ import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
-from mock import Mock
|
||||
+try:
|
||||
+ from unittest.mock import Mock
|
||||
+except ImportError:
|
||||
+ from mock import Mock
|
||||
|
||||
import pip._internal.req.req_uninstall
|
||||
from pip._internal.req.req_uninstall import (
|
Loading…
x
Reference in New Issue
Block a user