Skip to content

Commit a33ca80

Browse files
authored
Merge pull request #7156 from pradyunsg/remove-path-abspath
Rename tests.lib.path.Path.{abspath -> resolve()}
2 parents 732da2d + 37bc629 commit a33ca80

File tree

7 files changed

+14
-15
lines changed

7 files changed

+14
-15
lines changed

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def not_code_files_and_folders(path, names):
190190
# Copy over our source tree so that each use is self contained
191191
shutil.copytree(
192192
SRC_DIR,
193-
pip_src.abspath,
193+
pip_src.resolve(),
194194
ignore=not_code_files_and_folders,
195195
)
196196
return pip_src
@@ -222,7 +222,7 @@ def wheel_install(tmpdir_factory, common_wheels):
222222

223223
def install_egg_link(venv, project_name, egg_info_dir):
224224
with open(venv.site / 'easy-install.pth', 'a') as fp:
225-
fp.write(str(egg_info_dir.abspath) + '\n')
225+
fp.write(str(egg_info_dir.resolve()) + '\n')
226226
with open(venv.site / (project_name + '.egg-link'), 'w') as fp:
227227
fp.write(str(egg_info_dir) + '\n.')
228228

tests/functional/test_install.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,14 +456,14 @@ def test_hashed_install_success(script, data, tmpdir):
456456
457457
"""
458458
file_url = path_to_url(
459-
(data.packages / 'simple-1.0.tar.gz').abspath)
459+
(data.packages / 'simple-1.0.tar.gz').resolve())
460460
with requirements_file(
461461
'simple2==1.0 --hash=sha256:9336af72ca661e6336eb87bc7de3e8844d853e'
462462
'3848c2b9bbd2e8bf01db88c2c7\n'
463463
'{simple} --hash=sha256:393043e672415891885c9a2a0929b1af95fb866d6c'
464464
'a016b42d2e6ce53619b653'.format(simple=file_url),
465465
tmpdir) as reqs_file:
466-
script.pip_install_local('-r', reqs_file.abspath, expect_error=False)
466+
script.pip_install_local('-r', reqs_file.resolve(), expect_error=False)
467467

468468

469469
def test_hashed_install_failure(script, tmpdir):
@@ -478,7 +478,7 @@ def test_hashed_install_failure(script, tmpdir):
478478
'c7de3e8844d853e3848c2b9bbd2e8bf01db88c2c\n',
479479
tmpdir) as reqs_file:
480480
result = script.pip_install_local('-r',
481-
reqs_file.abspath,
481+
reqs_file.resolve(),
482482
expect_error=True)
483483
assert len(result.files_created) == 0
484484

tests/functional/test_install_reqs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def test_double_install_spurious_hash_mismatch(
371371
# Install a package (and build its wheel):
372372
result = script.pip_install_local(
373373
'--find-links', data.find_links,
374-
'-r', reqs_file.abspath, expect_error=False)
374+
'-r', reqs_file.resolve(), expect_error=False)
375375
assert 'Successfully installed simple-1.0' in str(result)
376376

377377
# Uninstall it:
@@ -381,7 +381,7 @@ def test_double_install_spurious_hash_mismatch(
381381
# package should install happily.
382382
result = script.pip_install_local(
383383
'--find-links', data.find_links,
384-
'-r', reqs_file.abspath, expect_error=False)
384+
'-r', reqs_file.resolve(), expect_error=False)
385385
assert 'Successfully installed simple-1.0' in str(result)
386386

387387

tests/lib/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
from pip._internal.models.target_python import TargetPython
2929

3030

31-
DATA_DIR = Path(__file__).parent.parent.joinpath("data").abspath
32-
SRC_DIR = Path(__file__).abspath.parent.parent.parent
31+
DATA_DIR = Path(__file__).parent.parent.joinpath("data").resolve()
32+
SRC_DIR = Path(__file__).resolve().parent.parent.parent
3333

3434
pyversion = get_major_minor_version()
3535
pyversion_tuple = sys.version_info
@@ -65,7 +65,7 @@ def _test_path_to_file_url(path):
6565
Args:
6666
path: a tests.lib.path.Path object.
6767
"""
68-
return 'file://' + path.abspath.replace('\\', '/')
68+
return 'file://' + path.resolve().replace('\\', '/')
6969

7070

7171
def create_file(path, contents=None):
@@ -155,7 +155,7 @@ class TestData(object):
155155

156156
def __init__(self, root, source=None):
157157
self.source = source or DATA_DIR
158-
self.root = Path(root).abspath
158+
self.root = Path(root).resolve()
159159

160160
@classmethod
161161
def copy(cls, root):

tests/lib/path.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ def suffix(self):
107107
"""
108108
return Path(os.path.splitext(self)[1])
109109

110-
@property
111-
def abspath(self):
110+
def resolve(self):
112111
"""
113112
'./a/bc.d' -> '/home/a/bc.d'
114113
"""

tests/unit/test_req.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def test_unpinned_hash_checking(self, data):
270270
def test_hash_mismatch(self, data):
271271
"""A hash mismatch should raise an error."""
272272
file_url = path_to_url(
273-
(data.packages / 'simple-1.0.tar.gz').abspath)
273+
(data.packages / 'simple-1.0.tar.gz').resolve())
274274
reqset = RequirementSet(require_hashes=True)
275275
reqset.add_requirement(get_processed_req_from_line(
276276
'%s --hash=sha256:badbad' % file_url, lineno=1,

tests/unit/test_req_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ def test_install_requirements_with_options(self, tmpdir, finder, session,
677677
'''.format(global_option=global_option, install_option=install_option)
678678

679679
with requirements_file(content, tmpdir) as reqs_file:
680-
req = next(parse_requirements(reqs_file.abspath,
680+
req = next(parse_requirements(reqs_file.resolve(),
681681
finder=finder,
682682
options=options,
683683
session=session))

0 commit comments

Comments
 (0)