mirror of https://github.com/pypa/pip
Fix test_locations unit tests on windows
This commit is contained in:
parent
02b8c98970
commit
fec74b29c0
|
@ -204,9 +204,11 @@ def distutils_scheme(dist_name, user=False, home=None, root=None,
|
|||
)
|
||||
|
||||
if root is not None:
|
||||
path_no_drive = os.path.splitdrive(
|
||||
os.path.abspath(scheme["headers"]))[1]
|
||||
scheme["headers"] = os.path.join(
|
||||
root,
|
||||
os.path.abspath(scheme["headers"])[1:],
|
||||
path_no_drive[1:],
|
||||
)
|
||||
|
||||
return scheme
|
||||
|
|
|
@ -77,17 +77,25 @@ class TestLocations:
|
|||
|
||||
class TestDisutilsScheme:
|
||||
|
||||
def test_root_modifies_appropiately(self):
|
||||
def test_root_modifies_appropriately(self, monkeypatch):
|
||||
# This deals with nt/posix path differences
|
||||
# root is c:\somewhere\else or /somewhere/else
|
||||
root = os.path.normcase(os.path.abspath(
|
||||
os.path.join(os.path.sep, 'somewhere', 'else')))
|
||||
norm_scheme = distutils_scheme("example")
|
||||
root_scheme = distutils_scheme("example", root="/test/root/")
|
||||
root_scheme = distutils_scheme("example", root=root)
|
||||
|
||||
for key, value in norm_scheme.items():
|
||||
expected = os.path.join("/test/root/", os.path.abspath(value)[1:])
|
||||
drive, path = os.path.splitdrive(os.path.abspath(value))
|
||||
expected = os.path.join(root, path[1:])
|
||||
assert os.path.abspath(root_scheme[key]) == expected
|
||||
|
||||
def test_distutils_config_file_read(self, tmpdir, monkeypatch):
|
||||
# This deals with nt/posix path differences
|
||||
install_scripts = os.path.normcase(os.path.abspath(
|
||||
os.path.join(os.path.sep, 'somewhere', 'else')))
|
||||
f = tmpdir.mkdir("config").join("setup.cfg")
|
||||
f.write("[install]\ninstall-scripts=/somewhere/else")
|
||||
f.write("[install]\ninstall-scripts=" + install_scripts)
|
||||
from distutils.dist import Distribution
|
||||
# patch the function that returns what config files are present
|
||||
monkeypatch.setattr(
|
||||
|
@ -96,14 +104,17 @@ class TestDisutilsScheme:
|
|||
lambda self: [f],
|
||||
)
|
||||
scheme = distutils_scheme('example')
|
||||
assert scheme['scripts'] == '/somewhere/else'
|
||||
assert scheme['scripts'] == install_scripts
|
||||
|
||||
# when we request install-lib, we should install everything (.py &
|
||||
# .so) into that path; i.e. ensure platlib & purelib are set to
|
||||
# this path
|
||||
def test_install_lib_takes_precedence(self, tmpdir, monkeypatch):
|
||||
# This deals with nt/posix path differences
|
||||
install_lib = os.path.normcase(os.path.abspath(
|
||||
os.path.join(os.path.sep, 'somewhere', 'else')))
|
||||
f = tmpdir.mkdir("config").join("setup.cfg")
|
||||
f.write("[install]\ninstall-lib=/somewhere/else/")
|
||||
f.write("[install]\ninstall-lib=" + install_lib)
|
||||
from distutils.dist import Distribution
|
||||
# patch the function that returns what config files are present
|
||||
monkeypatch.setattr(
|
||||
|
@ -112,5 +123,5 @@ class TestDisutilsScheme:
|
|||
lambda self: [f],
|
||||
)
|
||||
scheme = distutils_scheme('example')
|
||||
assert scheme['platlib'] == '/somewhere/else/'
|
||||
assert scheme['purelib'] == '/somewhere/else/'
|
||||
assert scheme['platlib'] == install_lib + os.path.sep
|
||||
assert scheme['purelib'] == install_lib + os.path.sep
|
||||
|
|
Loading…
Reference in New Issue