2013-01-23 05:52:35 +01:00
|
|
|
import os
|
2011-03-19 19:30:56 +01:00
|
|
|
import re
|
|
|
|
import textwrap
|
2012-09-13 18:22:19 +02:00
|
|
|
from tests.test_pip import pyversion, reset_env, run_pip, write_file
|
2012-12-18 06:34:37 +01:00
|
|
|
from tests.local_repos import local_checkout
|
2011-03-19 19:30:56 +01:00
|
|
|
|
|
|
|
|
2012-09-13 00:50:25 +02:00
|
|
|
def test_list_command():
|
|
|
|
"""
|
|
|
|
Test default behavior of list command.
|
|
|
|
|
|
|
|
"""
|
|
|
|
reset_env()
|
2012-10-02 00:52:13 +02:00
|
|
|
run_pip('install', 'INITools==0.2', 'mock==0.7.0')
|
2012-09-13 00:50:25 +02:00
|
|
|
result = run_pip('list')
|
2012-12-16 05:56:29 +01:00
|
|
|
assert 'INITools (0.2)' in result.stdout, str(result)
|
|
|
|
assert 'mock (0.7.0)' in result.stdout, str(result)
|
2012-09-13 00:50:25 +02:00
|
|
|
|
|
|
|
|
2012-09-13 00:57:41 +02:00
|
|
|
def test_local_flag():
|
2011-03-19 19:30:56 +01:00
|
|
|
"""
|
2012-09-13 00:57:41 +02:00
|
|
|
Test the behavior of --local flag in the list command
|
2012-09-13 00:50:25 +02:00
|
|
|
|
2011-03-19 19:30:56 +01:00
|
|
|
"""
|
2012-09-13 00:57:41 +02:00
|
|
|
reset_env()
|
2012-10-02 00:52:13 +02:00
|
|
|
run_pip('install', 'mock==0.7.0')
|
2012-09-13 00:57:41 +02:00
|
|
|
result = run_pip('list', '--local')
|
2012-10-02 00:52:13 +02:00
|
|
|
assert 'mock (0.7.0)' in result.stdout
|
2012-09-13 00:57:41 +02:00
|
|
|
|
2011-03-19 19:30:56 +01:00
|
|
|
|
2012-09-13 02:09:07 +02:00
|
|
|
def test_uptodate_flag():
|
|
|
|
"""
|
|
|
|
Test the behavior of --uptodate flag in the list command
|
|
|
|
|
|
|
|
"""
|
|
|
|
reset_env()
|
2012-09-13 21:39:08 +02:00
|
|
|
total_re = re.compile('INSTALLED: +([0-9.\w]+)')
|
2012-09-13 19:34:52 +02:00
|
|
|
run_pip('install', 'pytz', 'mock==0.8.0')
|
2012-12-18 06:34:37 +01:00
|
|
|
run_pip('install', '-e', 'git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package')
|
2012-09-13 21:39:08 +02:00
|
|
|
result = run_pip('search', 'pytz')
|
|
|
|
pytz_ver = total_re.search(str(result)).group(1)
|
2012-09-13 02:09:07 +02:00
|
|
|
result = run_pip('list', '--uptodate')
|
2012-09-13 21:39:08 +02:00
|
|
|
assert not 'mock (0.8.0)' in result.stdout
|
2012-12-18 06:34:37 +01:00
|
|
|
assert 'pip-test-package' not in result.stdout #editables excluded
|
2012-09-13 21:39:08 +02:00
|
|
|
assert 'pytz (%s)' % pytz_ver in result.stdout
|
2012-09-13 02:09:07 +02:00
|
|
|
|
|
|
|
|
2012-09-13 00:57:41 +02:00
|
|
|
def test_outdated_flag():
|
|
|
|
"""
|
|
|
|
Test the behavior of --outdated flag in the list command
|
|
|
|
|
|
|
|
"""
|
2011-03-19 19:30:56 +01:00
|
|
|
env = reset_env()
|
2012-09-13 19:34:52 +02:00
|
|
|
total_re = re.compile('LATEST: +([0-9.\w]+)')
|
2012-10-02 00:52:13 +02:00
|
|
|
write_file('req.txt', textwrap.dedent("""\
|
2011-03-19 19:30:56 +01:00
|
|
|
INITools==0.2
|
|
|
|
# and something else to test out:
|
2012-10-02 00:52:13 +02:00
|
|
|
mock==0.7.0
|
2012-12-18 06:34:37 +01:00
|
|
|
-e git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package
|
2012-10-02 19:47:30 +02:00
|
|
|
"""))
|
2012-10-02 00:52:13 +02:00
|
|
|
run_pip('install', '-r', env.scratch_path/'req.txt')
|
|
|
|
result = run_pip('search', 'mock')
|
|
|
|
mock_ver = total_re.search(str(result)).group(1)
|
2011-03-19 19:30:56 +01:00
|
|
|
result = run_pip('search', 'INITools')
|
|
|
|
initools_ver = total_re.search(str(result)).group(1)
|
2012-09-12 19:57:59 +02:00
|
|
|
result = run_pip('list', '--outdated', expect_stderr=True)
|
2012-12-20 07:08:56 +01:00
|
|
|
assert 'INITools (Current: 0.2 Latest: %s)' % initools_ver in result.stdout, str(result)
|
2012-12-18 06:34:37 +01:00
|
|
|
assert 'pip-test-package' not in result.stdout #editables excluded
|
2012-12-20 07:08:56 +01:00
|
|
|
assert 'mock (Current: 0.7.0 Latest: %s)' % mock_ver in result.stdout, str(result)
|
2012-12-18 06:34:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_editables_flag():
|
|
|
|
"""
|
|
|
|
Test the behavior of --editables flag in the list command
|
|
|
|
"""
|
|
|
|
reset_env()
|
|
|
|
run_pip('install', 'mock==0.7.0')
|
|
|
|
result = run_pip('install', '-e', 'git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package')
|
2012-12-20 07:08:56 +01:00
|
|
|
result = run_pip('list', '--editable')
|
2012-12-18 06:34:37 +01:00
|
|
|
assert 'mock (0.7.0)' not in result.stdout, str(result)
|
2013-01-23 05:52:35 +01:00
|
|
|
assert os.path.join('src', 'pip-test-package') in result.stdout, str(result)
|
2012-12-18 06:34:37 +01:00
|
|
|
|