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

Commit

Permalink
get_installed wasn't quite right
Browse files Browse the repository at this point in the history
  • Loading branch information
Buck Golemon committed Dec 11, 2014
1 parent cd733f1 commit f85123a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
13 changes: 9 additions & 4 deletions tests/functional/simple_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,19 @@ def install_twice(tmpdir, between):
return ratio


@pytest.mark.flaky(reruns=10)
@pytest.mark.flaky(reruns=5)
def test_noop_install_faster(tmpdir):
def do_nothing():
pass

# constrain both ends, to show that we know what's going on
assert 4 < install_twice(tmpdir, between=do_nothing) < 6
# 2014-12-10: osx, py27: 4.3, 4.6, 5.0, 5.3
# 2014-12-10: osx, py34: 8-9
# 2014-12-10: travis, py34: 11-12
assert 4 < install_twice(tmpdir, between=do_nothing) < 13


@pytest.mark.flaky(reruns=10)
@pytest.mark.flaky(reruns=5)
def test_cached_clean_install_faster(tmpdir):
def clean():
venv = tmpdir.join('virtualenv_run')
Expand All @@ -93,7 +96,9 @@ def clean():

# I get ~4x locally, but only 2.5x on travis
# constrain both ends, to show that we know what's going on
assert 2 < install_twice(tmpdir, between=clean) < 5
# 2014-12-10: osx, py34: 4.4, 4.6
# 2014-12-10: travis, py34: 6.5-7.0
assert 2 < install_twice(tmpdir, between=clean) < 7


def test_arguments_version(tmpdir, capfd):
Expand Down
2 changes: 2 additions & 0 deletions tests/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def run(*cmd, **env):
else:
env = None

from venv_update import colorize
check_call(('echo', 'TEST:', colorize(cmd)))
check_call(cmd, env=env)


Expand Down
17 changes: 8 additions & 9 deletions venv_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,12 @@ def dist_to_req(dist):
def pip_get_installed():
"""Code extracted from the middle of the pip freeze command.
"""
from pip.util import get_installed_distributions

installed = []
for dist in get_installed_distributions(local_only=True):
req = dist_to_req(dist)
installed.append(req)

return installed
from pip.util import dist_is_local
return tuple(
dist_to_req(dist)
for dist in fresh_working_set()
if dist_is_local(dist)
)


def pip_parse_requirements(requirement_files):
Expand Down Expand Up @@ -391,7 +389,8 @@ def do_install(reqs):
extraneous = (
reqnames(previously_installed) -
reqnames(required_with_deps) -
reqnames(recently_installed)
reqnames(recently_installed) -
set(['setuptools', 'pip'])
)

# 2) Uninstall any extraneous packages.
Expand Down

0 comments on commit f85123a

Please sign in to comment.