Skip to content

Commit

Permalink
Fix in-site-packages patch for user install tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed Dec 4, 2021
1 parent 6ed6aa8 commit 496343e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
11 changes: 4 additions & 7 deletions tests/functional/test_install_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@
def _patch_dist_in_site_packages(virtualenv: VirtualEnvironment) -> None:
# Since the tests are run from a virtualenv, and to avoid the "Will not
# install to the usersite because it will lack sys.path precedence..."
# error: Monkey patch `pip._internal.req.req_install.dist_in_site_packages`
# and `pip._internal.utils.misc.dist_in_site_packages`
# so it's possible to install a conflicting distribution in the user site.
# error: Monkey patch the Distribution class so it's possible to install a
# conflicting distribution in the user site.
virtualenv.sitecustomize = textwrap.dedent(
"""
def dist_in_site_packages(dist):
return False
from pip._internal.req import req_install
from pip._internal.utils import misc
req_install.dist_in_site_packages = dist_in_site_packages
misc.dist_in_site_packages = dist_in_site_packages
from pip._internal.metadata.base import BaseDistribution
BaseDistribution.in_site_packages = property(dist_in_site_packages)
"""
)

Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_new_resolver_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ def patch_dist_in_site_packages(virtualenv: VirtualEnvironment) -> None:
def dist_in_site_packages(dist):
return False
from pip._internal.utils import misc
misc.dist_in_site_packages = dist_in_site_packages
from pip._internal.metadata.base import BaseDistribution
BaseDistribution.in_site_packages = property(dist_in_site_packages)
"""
)

Expand Down

0 comments on commit 496343e

Please sign in to comment.