Merge pull request #7581 from chrahunt/refactor/split-install-tests

Split relative requirement install tests
This commit is contained in:
Christopher Hunt 2020-01-14 01:40:29 +08:00 committed by GitHub
commit cf722df4f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 18 deletions

View File

@ -406,7 +406,15 @@ def test_basic_install_from_local_directory(script, data):
assert egg_info_folder in result.files_created, str(result)
def test_basic_install_relative_directory(script, data):
@pytest.mark.parametrize("test_type,editable", [
("rel_path", False),
("rel_path", True),
("rel_url", False),
("rel_url", True),
("embedded_rel_path", False),
("embedded_rel_path", True),
])
def test_basic_install_relative_directory(script, data, test_type, editable):
"""
Test installing a requirement using a relative path.
"""
@ -427,21 +435,23 @@ def test_basic_install_relative_directory(script, data):
)
embedded_rel_path = script.scratch_path.joinpath(full_rel_path)
# For each relative path, install as either editable or not using either
# URLs with egg links or not.
for req_path in (full_rel_path, full_rel_url, embedded_rel_path):
# Regular install.
req_path = {
"rel_path": full_rel_path,
"rel_url": full_rel_url,
"embedded_rel_path": embedded_rel_path,
}[test_type]
# Install as either editable or not.
if not editable:
result = script.pip('install', req_path,
cwd=script.scratch_path)
assert egg_info_file in result.files_created, str(result)
assert package_folder in result.files_created, str(result)
script.pip('uninstall', '-y', 'fspkg')
else:
# Editable install.
result = script.pip('install', '-e' + req_path,
cwd=script.scratch_path)
assert egg_link_file in result.files_created, str(result)
script.pip('uninstall', '-y', 'fspkg')
def test_install_quiet(script, data):

View File

@ -57,7 +57,15 @@ def test_schema_check_in_requirements_file(script):
)
def test_relative_requirements_file(script, data):
@pytest.mark.parametrize("test_type,editable", [
("rel_path", False),
("rel_path", True),
("rel_url", False),
("rel_url", True),
("embedded_rel_path", False),
("embedded_rel_path", True),
])
def test_relative_requirements_file(script, data, test_type, editable):
"""
Test installing from a requirements file with a relative path. For path
URLs, use an egg= definition.
@ -78,26 +86,27 @@ def test_relative_requirements_file(script, data):
full_rel_url = 'file:' + full_rel_path + '#egg=FSPkg'
embedded_rel_path = script.scratch_path.joinpath(full_rel_path)
# For each relative path, install as either editable or not using either
# URLs with egg links or not.
for req_path in (full_rel_path, full_rel_url, embedded_rel_path):
req_path = req_path.replace(os.path.sep, '/')
# Regular install.
req_path = {
"rel_path": full_rel_path,
"rel_url": full_rel_url,
"embedded_rel_path": embedded_rel_path,
}[test_type]
req_path = req_path.replace(os.path.sep, '/')
# Install as either editable or not.
if not editable:
with requirements_file(req_path + '\n',
script.scratch_path) as reqs_file:
result = script.pip('install', '-vvv', '-r', reqs_file.name,
cwd=script.scratch_path)
assert egg_info_file in result.files_created, str(result)
assert package_folder in result.files_created, str(result)
script.pip('uninstall', '-y', 'fspkg')
# Editable install.
else:
with requirements_file('-e ' + req_path + '\n',
script.scratch_path) as reqs_file:
result = script.pip('install', '-vvv', '-r', reqs_file.name,
cwd=script.scratch_path)
assert egg_link_file in result.files_created, str(result)
script.pip('uninstall', '-y', 'fspkg')
@pytest.mark.network