Skip to content

Commit 732da2d

Browse files
authored
Remove tests.lib.path.Path.__sub__ (#7151)
2 parents 49d2919 + 3ff9061 commit 732da2d

File tree

4 files changed

+19
-26
lines changed

4 files changed

+19
-26
lines changed

tests/functional/test_install.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ def test_basic_install_relative_directory(script, data):
407407
package_folder = script.site_packages / 'fspkg'
408408

409409
# Compute relative install path to FSPkg from scratch path.
410-
full_rel_path = data.packages.joinpath('FSPkg') - script.scratch_path
410+
full_rel_path = Path(
411+
os.path.relpath(data.packages.joinpath('FSPkg'), script.scratch_path)
412+
)
411413
full_rel_url = (
412414
'file:' + full_rel_path.replace(os.path.sep, '/') + '#egg=FSPkg'
413415
)
@@ -1554,11 +1556,13 @@ def test_target_install_ignores_distutils_config_install_prefix(script):
15541556
''' % str(prefix)))
15551557
target = script.scratch_path / 'target'
15561558
result = script.pip_install_local('simplewheel', '-t', target)
1557-
assert (
1558-
"Successfully installed simplewheel" in result.stdout and
1559-
(target - script.base_path) in result.files_created and
1560-
(prefix - script.base_path) not in result.files_created
1561-
), str(result)
1559+
1560+
assert "Successfully installed simplewheel" in result.stdout
1561+
1562+
relative_target = os.path.relpath(target, script.base_path)
1563+
relative_script_base = os.path.relpath(prefix, script.base_path)
1564+
assert relative_target in result.files_created
1565+
assert relative_script_base not in result.files_created
15621566

15631567

15641568
@pytest.mark.network

tests/functional/test_install_reqs.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
requirements_file,
1111
)
1212
from tests.lib.local_repos import local_checkout
13+
from tests.lib.path import Path
1314

1415

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

7273
# Compute relative install path to FSPkg from scratch path.
73-
full_rel_path = data.packages.joinpath('FSPkg') - script.scratch_path
74+
full_rel_path = Path(
75+
os.path.relpath(data.packages.joinpath('FSPkg'), script.scratch_path)
76+
)
7477
full_rel_url = 'file:' + full_rel_path + '#egg=FSPkg'
7578
embedded_rel_path = script.scratch_path.joinpath(full_rel_path)
7679

tests/lib/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def __init__(self, base_path, *args, **kwargs):
447447
self.user_bin_path = scripts_base.joinpath('Scripts')
448448
else:
449449
self.user_bin_path = self.user_base_path.joinpath(
450-
self.bin_path - self.venv_path
450+
os.path.relpath(self.bin_path, self.venv_path)
451451
)
452452

453453
# Create a Directory to use as a scratch pad
@@ -483,7 +483,10 @@ def __init__(self, base_path, *args, **kwargs):
483483
for name in ["base", "venv", "bin", "lib", "site_packages",
484484
"user_base", "user_site", "user_bin", "scratch"]:
485485
real_name = "%s_path" % name
486-
setattr(self, name, getattr(self, real_name) - self.base_path)
486+
relative_path = Path(os.path.relpath(
487+
getattr(self, real_name), self.base_path
488+
))
489+
setattr(self, name, relative_path)
487490

488491
# Make sure temp_path is a Path object
489492
self.temp_path = Path(self.temp_path)

tests/lib/path.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,6 @@ def __idiv__(self, path):
6666

6767
__itruediv__ = __idiv__
6868

69-
def __sub__(self, path):
70-
"""
71-
Makes this path relative to another path.
72-
73-
>>> path_obj - '/home/a'
74-
>>> path_obj - path_obj2
75-
"""
76-
return Path(os.path.relpath(self, path))
77-
78-
def __rsub__(self, path):
79-
"""
80-
Returns path relative to this path.
81-
82-
>>> "/home/a" - path_obj
83-
"""
84-
return Path(os.path.relpath(path, self))
85-
8669
def __add__(self, path):
8770
"""
8871
>>> Path('/home/a') + 'bc.d'

0 commit comments

Comments
 (0)