2012-09-11 22:44:42 +02:00
|
|
|
import re
|
2012-09-07 22:31:56 +02:00
|
|
|
from pip import __version__
|
2012-09-12 18:39:19 +02:00
|
|
|
from pip.commands.show import search_packages_info
|
2012-09-07 22:31:56 +02:00
|
|
|
|
2012-09-07 23:28:18 +02:00
|
|
|
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_show(script):
|
2012-09-07 22:31:56 +02:00
|
|
|
"""
|
2012-09-12 18:39:19 +02:00
|
|
|
Test end to end test for show command.
|
2012-09-07 22:31:56 +02:00
|
|
|
"""
|
2013-08-21 11:16:07 +02:00
|
|
|
result = script.pip('show', 'pip')
|
2012-09-07 22:31:56 +02:00
|
|
|
lines = result.stdout.split('\n')
|
2012-09-21 19:15:24 +02:00
|
|
|
assert len(lines) == 6
|
2012-09-11 22:44:42 +02:00
|
|
|
assert lines[0] == '---', lines[0]
|
|
|
|
assert lines[1] == 'Name: pip', lines[1]
|
|
|
|
assert lines[2] == 'Version: %s' % __version__, lines[2]
|
|
|
|
assert lines[3].startswith('Location: '), lines[3]
|
2012-09-21 19:15:24 +02:00
|
|
|
assert lines[4] == 'Requires: '
|
2012-09-11 22:44:42 +02:00
|
|
|
|
|
|
|
|
2014-03-12 06:31:41 +01:00
|
|
|
def test_show_with_files_not_found(script, data):
|
2012-09-11 22:44:42 +02:00
|
|
|
"""
|
2012-09-12 18:39:19 +02:00
|
|
|
Test for show command with installed files listing enabled and
|
2012-09-11 22:44:42 +02:00
|
|
|
installed-files.txt not found.
|
|
|
|
"""
|
2014-03-12 06:31:41 +01:00
|
|
|
editable = data.packages.join('SetupPyUTF8')
|
|
|
|
script.pip('install', '-e', editable)
|
|
|
|
result = script.pip('show', '-f', 'SetupPyUTF8')
|
2012-09-11 22:44:42 +02:00
|
|
|
lines = result.stdout.split('\n')
|
2012-09-21 19:15:24 +02:00
|
|
|
assert len(lines) == 8
|
2012-09-08 23:31:59 +02:00
|
|
|
assert lines[0] == '---', lines[0]
|
2014-03-12 06:31:41 +01:00
|
|
|
assert lines[1] == 'Name: SetupPyUTF8', lines[1]
|
|
|
|
assert lines[2] == 'Version: 0.0.0', lines[2]
|
2012-09-08 23:31:59 +02:00
|
|
|
assert lines[3].startswith('Location: '), lines[3]
|
2014-03-12 06:31:41 +01:00
|
|
|
assert lines[4] == 'Requires: ', lines[4]
|
|
|
|
assert lines[5] == 'Files:', lines[5]
|
|
|
|
assert lines[6] == 'Cannot locate installed-files.txt', lines[6]
|
|
|
|
|
|
|
|
|
|
|
|
def test_show_with_files_from_wheel(script, data):
|
|
|
|
"""
|
|
|
|
Test that a wheel's files can be listed
|
|
|
|
"""
|
|
|
|
wheel_file = data.packages.join('simple.dist-0.1-py2.py3-none-any.whl')
|
|
|
|
script.pip('install', '--no-index', wheel_file)
|
|
|
|
result = script.pip('show', '-f', 'simple.dist')
|
|
|
|
lines = result.stdout.split('\n')
|
|
|
|
assert lines[1] == 'Name: simple.dist', lines[1]
|
|
|
|
assert 'Cannot locate installed-files.txt' not in lines[6], lines[6]
|
|
|
|
assert re.search(r"Files:\n( .+\n)+", result.stdout)
|
2012-09-07 23:17:04 +02:00
|
|
|
|
|
|
|
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_show_with_all_files(script):
|
2012-09-11 22:44:42 +02:00
|
|
|
"""
|
2012-09-12 18:39:19 +02:00
|
|
|
Test listing all files in the show command.
|
2012-09-11 22:44:42 +02:00
|
|
|
"""
|
2014-03-12 06:31:41 +01:00
|
|
|
script.pip('install', 'initools==0.2')
|
2013-08-21 11:16:07 +02:00
|
|
|
result = script.pip('show', '--files', 'initools')
|
2014-03-12 06:31:41 +01:00
|
|
|
lines = result.stdout.split('\n')
|
|
|
|
assert 'Cannot locate installed-files.txt' not in lines[6], lines[6]
|
2012-09-11 22:44:42 +02:00
|
|
|
assert re.search(r"Files:\n( .+\n)+", result.stdout)
|
|
|
|
|
|
|
|
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_missing_argument(script):
|
2012-09-07 23:28:18 +02:00
|
|
|
"""
|
2012-09-12 18:39:19 +02:00
|
|
|
Test show command with no arguments.
|
2012-09-07 23:28:18 +02:00
|
|
|
"""
|
2013-08-21 11:16:07 +02:00
|
|
|
result = script.pip('show')
|
2013-01-18 22:25:15 +01:00
|
|
|
assert 'ERROR: Please provide a package name or names.' in result.stdout
|
2012-09-07 23:28:18 +02:00
|
|
|
|
|
|
|
|
2012-09-07 23:17:04 +02:00
|
|
|
def test_find_package_not_found():
|
|
|
|
"""
|
2012-09-08 23:31:59 +02:00
|
|
|
Test trying to get info about a nonexistent package.
|
2012-09-07 23:17:04 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
result = search_packages_info(['abcd3'])
|
|
|
|
assert len(list(result)) == 0
|
|
|
|
|
|
|
|
|
|
|
|
def test_search_any_case():
|
|
|
|
"""
|
|
|
|
Search for a package in any case.
|
|
|
|
|
|
|
|
"""
|
|
|
|
result = list(search_packages_info(['PIP']))
|
|
|
|
assert len(result) == 1
|
|
|
|
assert 'pip' == result[0]['name']
|
2012-09-07 23:28:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_more_than_one_package():
|
|
|
|
"""
|
|
|
|
Search for more than one package.
|
|
|
|
|
|
|
|
"""
|
2013-08-18 11:59:44 +02:00
|
|
|
result = list(search_packages_info(['Pip', 'pytest', 'Virtualenv']))
|
2012-09-07 23:28:18 +02:00
|
|
|
assert len(result) == 3
|