Skip to content

Commit 496343e

Browse files
committed
Fix in-site-packages patch for user install tests
1 parent 6ed6aa8 commit 496343e

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

tests/functional/test_install_user.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@
1616
def _patch_dist_in_site_packages(virtualenv: VirtualEnvironment) -> None:
1717
# Since the tests are run from a virtualenv, and to avoid the "Will not
1818
# install to the usersite because it will lack sys.path precedence..."
19-
# error: Monkey patch `pip._internal.req.req_install.dist_in_site_packages`
20-
# and `pip._internal.utils.misc.dist_in_site_packages`
21-
# so it's possible to install a conflicting distribution in the user site.
19+
# error: Monkey patch the Distribution class so it's possible to install a
20+
# conflicting distribution in the user site.
2221
virtualenv.sitecustomize = textwrap.dedent(
2322
"""
2423
def dist_in_site_packages(dist):
2524
return False
2625
27-
from pip._internal.req import req_install
28-
from pip._internal.utils import misc
29-
req_install.dist_in_site_packages = dist_in_site_packages
30-
misc.dist_in_site_packages = dist_in_site_packages
26+
from pip._internal.metadata.base import BaseDistribution
27+
BaseDistribution.in_site_packages = property(dist_in_site_packages)
3128
"""
3229
)
3330

tests/functional/test_new_resolver_user.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ def patch_dist_in_site_packages(virtualenv: VirtualEnvironment) -> None:
135135
def dist_in_site_packages(dist):
136136
return False
137137
138-
from pip._internal.utils import misc
139-
misc.dist_in_site_packages = dist_in_site_packages
138+
from pip._internal.metadata.base import BaseDistribution
139+
BaseDistribution.in_site_packages = property(dist_in_site_packages)
140140
"""
141141
)
142142

0 commit comments

Comments
 (0)