Skip to content

Rename tests.lib.path.Path.{abspath -> resolve()} #7156

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 1 commit 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
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def not_code_files_and_folders(path, names):
# Copy over our source tree so that each use is self contained
shutil.copytree(
SRC_DIR,
pip_src.abspath,
pip_src.resolve(),
ignore=not_code_files_and_folders,
)
return pip_src
Expand Down Expand Up @@ -222,7 +222,7 @@ def wheel_install(tmpdir_factory, common_wheels):

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

Expand Down
6 changes: 3 additions & 3 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,14 @@ def test_hashed_install_success(script, data, tmpdir):

"""
file_url = path_to_url(
(data.packages / 'simple-1.0.tar.gz').abspath)
(data.packages / 'simple-1.0.tar.gz').resolve())
with requirements_file(
'simple2==1.0 --hash=sha256:9336af72ca661e6336eb87bc7de3e8844d853e'
'3848c2b9bbd2e8bf01db88c2c7\n'
'{simple} --hash=sha256:393043e672415891885c9a2a0929b1af95fb866d6c'
'a016b42d2e6ce53619b653'.format(simple=file_url),
tmpdir) as reqs_file:
script.pip_install_local('-r', reqs_file.abspath, expect_error=False)
script.pip_install_local('-r', reqs_file.resolve(), expect_error=False)


def test_hashed_install_failure(script, tmpdir):
Expand All @@ -478,7 +478,7 @@ def test_hashed_install_failure(script, tmpdir):
'c7de3e8844d853e3848c2b9bbd2e8bf01db88c2c\n',
tmpdir) as reqs_file:
result = script.pip_install_local('-r',
reqs_file.abspath,
reqs_file.resolve(),
expect_error=True)
assert len(result.files_created) == 0

Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_install_reqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def test_double_install_spurious_hash_mismatch(
# Install a package (and build its wheel):
result = script.pip_install_local(
'--find-links', data.find_links,
'-r', reqs_file.abspath, expect_error=False)
'-r', reqs_file.resolve(), expect_error=False)
assert 'Successfully installed simple-1.0' in str(result)

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


Expand Down
8 changes: 4 additions & 4 deletions tests/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
from pip._internal.models.target_python import TargetPython


DATA_DIR = Path(__file__).parent.parent.joinpath("data").abspath
SRC_DIR = Path(__file__).abspath.parent.parent.parent
DATA_DIR = Path(__file__).parent.parent.joinpath("data").resolve()
SRC_DIR = Path(__file__).resolve().parent.parent.parent

pyversion = get_major_minor_version()
pyversion_tuple = sys.version_info
Expand Down Expand Up @@ -65,7 +65,7 @@ def _test_path_to_file_url(path):
Args:
path: a tests.lib.path.Path object.
"""
return 'file://' + path.abspath.replace('\\', '/')
return 'file://' + path.resolve().replace('\\', '/')


def create_file(path, contents=None):
Expand Down Expand Up @@ -155,7 +155,7 @@ class TestData(object):

def __init__(self, root, source=None):
self.source = source or DATA_DIR
self.root = Path(root).abspath
self.root = Path(root).resolve()

@classmethod
def copy(cls, root):
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ def suffix(self):
"""
return Path(os.path.splitext(self)[1])

@property
def abspath(self):
def resolve(self):
"""
'./a/bc.d' -> '/home/a/bc.d'
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_req.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def test_unpinned_hash_checking(self, data):
def test_hash_mismatch(self, data):
"""A hash mismatch should raise an error."""
file_url = path_to_url(
(data.packages / 'simple-1.0.tar.gz').abspath)
(data.packages / 'simple-1.0.tar.gz').resolve())
reqset = RequirementSet(require_hashes=True)
reqset.add_requirement(get_processed_req_from_line(
'%s --hash=sha256:badbad' % file_url, lineno=1,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def test_install_requirements_with_options(self, tmpdir, finder, session,
'''.format(global_option=global_option, install_option=install_option)

with requirements_file(content, tmpdir) as reqs_file:
req = next(parse_requirements(reqs_file.abspath,
req = next(parse_requirements(reqs_file.resolve(),
finder=finder,
options=options,
session=session))
Expand Down