Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
try to fix up the argparse insanity
Browse files Browse the repository at this point in the history
  • Loading branch information
bukzor committed Jan 7, 2015
1 parent cba2ab1 commit 471a89b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
17 changes: 12 additions & 5 deletions tests/functional/get_installed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ def get_installed():
print(p)''', venv='myvenv')

assert err == ''

# Most python distributions which have argparse in the stdlib fail to
# expose it to setuptools as an installed package (it seems all but ubuntu
# do this). This results in argparse sometimes being installed locally,
# sometimes not, even for a specific version of python.
# We normalize by never looking at argparse =/
out = out.replace('argparse\n', '', 1)

return out.split()


Expand All @@ -23,18 +31,17 @@ def test_pip_get_installed(tmpdir):

run(
'myvenv/bin/pip', 'install',
'argparse==1.2.1',
'hg+https://bitbucket.org/bukzor/coverage.py@__main__-support#egg=coverage',
'git+git://github.com/bukzor/cov-core.git@master#egg=cov-core',
'-e', 'git+git://github.com/bukzor/pytest-cov.git@master#egg=pytest-cov',
)
assert get_installed() == ['argparse', 'cov-core', 'coverage', 'pip', 'py', 'pytest', 'pytest-cov', 'setuptools']
assert get_installed() == ['cov-core', 'coverage', 'pip', 'py', 'pytest', 'pytest-cov', 'setuptools']

run('myvenv/bin/pip', 'uninstall', '--yes', 'cov-core', 'coverage', 'py', 'pytest', 'pytest-cov')
assert get_installed() == ['argparse', 'pip', 'setuptools']
assert get_installed() == ['pip', 'setuptools']

run('myvenv/bin/pip', 'install', 'flake8')
assert get_installed() == ['argparse', 'flake8', 'mccabe', 'pep8', 'pip', 'pyflakes', 'setuptools']
assert get_installed() == ['flake8', 'mccabe', 'pep8', 'pip', 'pyflakes', 'setuptools']

run('myvenv/bin/pip', 'uninstall', '--yes', 'flake8')
assert get_installed() == ['argparse', 'mccabe', 'pep8', 'pip', 'pyflakes', 'setuptools']
assert get_installed() == ['mccabe', 'pep8', 'pip', 'pyflakes', 'setuptools']
26 changes: 13 additions & 13 deletions tests/functional/simple_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def install_twice(tmpdir, between):
time1 = time() - start
assert pip_freeze() == '\n'.join((
'PyYAML==3.11',
'argparse==1.2.1',
'astroid==1.3.2',
'chroniker==0.0.0',
'logilab-common==0.63.2',
Expand All @@ -87,16 +86,15 @@ def install_twice(tmpdir, between):

start = time()
# second install should also need no network access
# these are arbitrary invalid IP's
# these are arbitrary invalid addresses
venv_update(
http_proxy='http://300.10.20.30:40',
https_proxy='http://400.11.22.33:44',
ftp_proxy='http://500.4.3.2:1',
http_proxy='foo-proxy',
https_proxy='bar-proxy',
ftp_proxy='quux-proxy',
)
time2 = time() - start
assert pip_freeze() == '\n'.join((
'PyYAML==3.11',
'argparse==1.2.1',
'astroid==1.3.2',
'chroniker==0.0.0',
'logilab-common==0.63.2',
Expand Down Expand Up @@ -189,13 +187,15 @@ def test_arguments_system_packages(tmpdir):
assert out and Path(out).isdir()


def pip(*args):
# because the scripts are made relative, it won't use the venv python without being explicit.
return run('virtualenv_run/bin/python', 'virtualenv_run/bin/pip', *args)


def pip_freeze():
out, err = pip('freeze', '--local')
out, err = run('./virtualenv_run/bin/pip', 'freeze', '--local')

# Most python distributions which have argparse in the stdlib fail to
# expose it to setuptools as an installed package (it seems all but ubuntu
# do this). This results in argparse sometimes being installed locally,
# sometimes not, even for a specific version of python.
# We normalize by never looking at argparse =/
out = out.replace('argparse==1.2.1\n', '', 1)

assert err == ''
return out
Expand Down Expand Up @@ -261,7 +261,7 @@ def test_scripts_left_behind(tmpdir):
script_path = Path('virtualenv_run/bin/pep8')
assert not script_path.exists()

pip('install', 'pep8')
run('virtualenv_run/bin/pip', 'install', 'pep8')
assert script_path.exists()

venv_update()
Expand Down

0 comments on commit 471a89b

Please sign in to comment.