Skip to content

Remove tests.lib.path.Path.__sub__ #7151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,9 @@ def test_basic_install_relative_directory(script, data):
package_folder = script.site_packages / 'fspkg'

# Compute relative install path to FSPkg from scratch path.
full_rel_path = data.packages.joinpath('FSPkg') - script.scratch_path
full_rel_path = Path(
os.path.relpath(data.packages.joinpath('FSPkg'), script.scratch_path)
)
full_rel_url = (
'file:' + full_rel_path.replace(os.path.sep, '/') + '#egg=FSPkg'
)
Expand Down Expand Up @@ -1553,11 +1555,13 @@ def test_target_install_ignores_distutils_config_install_prefix(script):
''' % str(prefix)))
target = script.scratch_path / 'target'
result = script.pip_install_local('simplewheel', '-t', target)
assert (
"Successfully installed simplewheel" in result.stdout and
(target - script.base_path) in result.files_created and
(prefix - script.base_path) not in result.files_created
), str(result)

assert "Successfully installed simplewheel" in result.stdout

relative_target = os.path.relpath(target, script.base_path)
relative_script_base = os.path.relpath(prefix, script.base_path)
assert relative_target in result.files_created
assert relative_script_base not in result.files_created


@pytest.mark.network
Expand Down
5 changes: 4 additions & 1 deletion tests/functional/test_install_reqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
requirements_file,
)
from tests.lib.local_repos import local_checkout
from tests.lib.path import Path


@pytest.mark.network
Expand Down Expand Up @@ -70,7 +71,9 @@ def test_relative_requirements_file(script, data):
package_folder = script.site_packages / 'fspkg'

# Compute relative install path to FSPkg from scratch path.
full_rel_path = data.packages.joinpath('FSPkg') - script.scratch_path
full_rel_path = Path(
os.path.relpath(data.packages.joinpath('FSPkg'), script.scratch_path)
)
full_rel_url = 'file:' + full_rel_path + '#egg=FSPkg'
embedded_rel_path = script.scratch_path.joinpath(full_rel_path)

Expand Down
7 changes: 5 additions & 2 deletions tests/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def __init__(self, base_path, *args, **kwargs):
self.user_bin_path = scripts_base.joinpath('Scripts')
else:
self.user_bin_path = self.user_base_path.joinpath(
self.bin_path - self.venv_path
os.path.relpath(self.bin_path, self.venv_path)
)

# Create a Directory to use as a scratch pad
Expand Down Expand Up @@ -482,7 +482,10 @@ def __init__(self, base_path, *args, **kwargs):
for name in ["base", "venv", "bin", "lib", "site_packages",
"user_base", "user_site", "user_bin", "scratch"]:
real_name = "%s_path" % name
setattr(self, name, getattr(self, real_name) - self.base_path)
relative_path = Path(os.path.relpath(
getattr(self, real_name), self.base_path
))
setattr(self, name, relative_path)

# Make sure temp_path is a Path object
self.temp_path = Path(self.temp_path)
Expand Down
17 changes: 0 additions & 17 deletions tests/lib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,6 @@ def __idiv__(self, path):

__itruediv__ = __idiv__

def __sub__(self, path):
"""
Makes this path relative to another path.

>>> path_obj - '/home/a'
>>> path_obj - path_obj2
"""
return Path(os.path.relpath(self, path))

def __rsub__(self, path):
"""
Returns path relative to this path.

>>> "/home/a" - path_obj
"""
return Path(os.path.relpath(path, self))

def __add__(self, path):
"""
>>> Path('/home/a') + 'bc.d'
Expand Down