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 6, 2015
1 parent cba2ab1 commit a6c4d3d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
19 changes: 13 additions & 6 deletions tests/functional/get_installed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ def get_installed():
print(p)''', venv='myvenv')

assert err == ''
return out.split()

# Many python distributions which have argparse in the stdlib fail to
# expose it to setuptools as an installed package. This results in argparse
# sometimes being installed locally, sometimes not. We normalize by never
# looking at it =/
result = out.split()
if 'argparse' in result:
result.remove('argparse')
return result


def test_pip_get_installed(tmpdir):
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']
23 changes: 10 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 IP's, with invalid ports
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='http://300.10.20.30:404040',
https_proxy='http://400.11.22.33:444444',
ftp_proxy='http://500.4.3.2:111111',
)
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,12 @@ 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')
# Many python distributions which have argparse in the stdlib fail to
# expose it to setuptools as an installed package. This results in argparse
# sometimes being installed locally, sometimes not. We normalize by never
# looking at it =/
out, err = run('sh', '-c', './virtualenv_run/bin/pip freeze --local | grep -vw argparse')

assert err == ''
return out
Expand Down Expand Up @@ -261,7 +258,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 a6c4d3d

Please sign in to comment.