mirror of https://github.com/pypa/pip
Merge pull request #612 from qwcode/issue_420
test enhancements to pull #599 (which fixes issue #420)
This commit is contained in:
commit
fa8c738b30
|
@ -6,6 +6,7 @@ Armin Ronacher
|
|||
Brian Rosner
|
||||
Carl Meyer
|
||||
Christian Oudard
|
||||
Clay McClure
|
||||
Cody Soyland
|
||||
Daniel Holth
|
||||
Dave Abrahams
|
||||
|
|
|
@ -895,7 +895,7 @@ class RequirementSet(object):
|
|||
req.commit_uninstall()
|
||||
|
||||
def locate_files(self):
|
||||
## FIXME: duplicates code from install_files; relevant code should
|
||||
## FIXME: duplicates code from prepare_files; relevant code should
|
||||
## probably be factored out into a separate method
|
||||
unnamed = list(self.unnamed_requirements)
|
||||
reqs = list(self.requirements.values())
|
||||
|
@ -1003,7 +1003,9 @@ class RequirementSet(object):
|
|||
##occurs when the script attempts to unpack the
|
||||
##build directory
|
||||
|
||||
# NB: This call can result in the creation of a temporary build directory
|
||||
location = req_to_install.build_location(self.build_dir, not self.is_download)
|
||||
|
||||
## FIXME: is the existance of the checkout good enough to use it? I don't think so.
|
||||
unpack = True
|
||||
url = None
|
||||
|
@ -1084,7 +1086,7 @@ class RequirementSet(object):
|
|||
self.add_requirement(subreq)
|
||||
if req_to_install.name not in self.requirements:
|
||||
self.requirements[req_to_install.name] = req_to_install
|
||||
if self.is_download:
|
||||
if self.is_download or req_to_install._temp_build_dir is not None:
|
||||
self.reqs_to_cleanup.append(req_to_install)
|
||||
else:
|
||||
self.reqs_to_cleanup.append(req_to_install)
|
||||
|
|
|
@ -17,6 +17,7 @@ def test_cleanup_after_install_from_pypi():
|
|||
src = env.scratch_path/"src"
|
||||
assert not exists(build), "build/ dir still exists: %s" % build
|
||||
assert not exists(src), "unexpected src/ dir exists: %s" % src
|
||||
env.assert_no_temp()
|
||||
|
||||
|
||||
def test_cleanup_after_install_editable_from_hg():
|
||||
|
@ -34,6 +35,7 @@ def test_cleanup_after_install_editable_from_hg():
|
|||
src = env.venv_path/'src'
|
||||
assert not exists(build), "build/ dir still exists: %s" % build
|
||||
assert exists(src), "expected src/ dir doesn't exist: %s" % src
|
||||
env.assert_no_temp()
|
||||
|
||||
|
||||
def test_cleanup_after_install_from_local_directory():
|
||||
|
@ -48,6 +50,7 @@ def test_cleanup_after_install_from_local_directory():
|
|||
src = env.venv_path/'src'
|
||||
assert not exists(build), "unexpected build/ dir exists: %s" % build
|
||||
assert not exists(src), "unexpected src/ dir exist: %s" % src
|
||||
env.assert_no_temp()
|
||||
|
||||
|
||||
def test_cleanup_after_create_bundle():
|
||||
|
@ -79,6 +82,7 @@ def test_cleanup_after_create_bundle():
|
|||
src_bundle = env.scratch_path/"src-bundle"
|
||||
assert not exists(build_bundle), "build-bundle/ dir still exists: %s" % build_bundle
|
||||
assert not exists(src_bundle), "src-bundle/ dir still exists: %s" % src_bundle
|
||||
env.assert_no_temp()
|
||||
|
||||
# Make sure previously created src/ from editable still exists
|
||||
assert exists(src), "expected src dir doesn't exist: %s" % src
|
||||
|
@ -96,6 +100,25 @@ def test_no_install_and_download_should_not_leave_build_dir():
|
|||
assert not os.path.exists(env.venv_path/'/build'), "build/ dir should be deleted"
|
||||
|
||||
|
||||
def test_cleanup_req_satisifed_no_name():
|
||||
"""
|
||||
Test cleanup when req is already satisfied, and req has no 'name'
|
||||
"""
|
||||
#this test confirms Issue #420 is fixed
|
||||
#reqs with no 'name' that were already satisfied were leaving behind tmp build dirs
|
||||
#2 examples of reqs that would do this
|
||||
# 1) https://bitbucket.org/ianb/initools/get/tip.zip
|
||||
# 2) parent-0.1.tar.gz
|
||||
|
||||
dist = abspath(join(here, 'packages', 'parent-0.1.tar.gz'))
|
||||
env = reset_env()
|
||||
result = run_pip('install', dist)
|
||||
result = run_pip('install', dist)
|
||||
build = env.venv_path/'build'
|
||||
assert not exists(build), "unexpected build/ dir exists: %s" % build
|
||||
env.assert_no_temp()
|
||||
|
||||
|
||||
def test_download_should_not_delete_existing_build_dir():
|
||||
"""
|
||||
It should not delete build/ if existing before run the command
|
||||
|
|
|
@ -365,6 +365,10 @@ class TestPipEnvironment(TestFileEnvironment):
|
|||
if sitecustomize:
|
||||
self._add_to_sitecustomize(sitecustomize)
|
||||
|
||||
# Ensure that $TMPDIR exists (because we use start_clear=False, it's not created for us)
|
||||
if self.temp_path and not os.path.exists(self.temp_path):
|
||||
os.makedirs(self.temp_path)
|
||||
|
||||
def _ignore_file(self, fn):
|
||||
if fn.endswith('__pycache__') or fn.endswith(".pyc"):
|
||||
result = True
|
||||
|
@ -516,6 +520,10 @@ class FastTestPipEnvironment(TestPipEnvironment):
|
|||
|
||||
assert self.root_path.exists
|
||||
|
||||
# Ensure that $TMPDIR exists (because we use start_clear=False, it's not created for us)
|
||||
if self.temp_path and not os.path.exists(self.temp_path):
|
||||
os.makedirs(self.temp_path)
|
||||
|
||||
def __del__(self):
|
||||
pass # shutil.rmtree(str(self.root_path), ignore_errors=True)
|
||||
|
||||
|
@ -669,5 +677,5 @@ def _change_test_package_version(env, version_pkg_path):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.stderr.write("Run pip's tests using nosetests. Requires virtualenv, ScriptTest, and nose.\n")
|
||||
sys.stderr.write("Run pip's tests using nosetests. Requires virtualenv, ScriptTest, mock, and nose.\n")
|
||||
sys.exit(1)
|
||||
|
|
|
@ -66,3 +66,24 @@ def test_sitecustomize_not_growing_in_fast_environment():
|
|||
size2 = os.stat(sc2).st_size
|
||||
assert size1==size2, "size before, %d != size after, %d" %(size1, size2)
|
||||
|
||||
|
||||
def test_tmp_dir_exists_in_env():
|
||||
"""
|
||||
Test that $TMPDIR == env.temp_path and path exists, and env.assert_no_temp() passes
|
||||
"""
|
||||
#need these tests to ensure the assert_no_temp feature of scripttest is working
|
||||
env = reset_env(use_distribute=True)
|
||||
env.assert_no_temp() #this fails if env.tmp_path doesn't exist
|
||||
assert env.environ['TMPDIR'] == env.temp_path
|
||||
assert isdir(env.temp_path)
|
||||
|
||||
|
||||
def test_tmp_dir_exists_in_fast_env():
|
||||
"""
|
||||
Test that $TMPDIR == env.temp_path and path exists and env.assert_no_temp() passes (in fast env)
|
||||
"""
|
||||
#need these tests to ensure the assert_no_temp feature of scripttest is working
|
||||
env = reset_env()
|
||||
env.assert_no_temp() #this fails if env.tmp_path doesn't exist
|
||||
assert env.environ['TMPDIR'] == env.temp_path
|
||||
assert isdir(env.temp_path)
|
||||
|
|
|
@ -20,6 +20,6 @@ def test_install_package_that_emits_unicode():
|
|||
|
||||
env = reset_env()
|
||||
to_install = os.path.abspath(os.path.join(here, 'packages', 'BrokenEmitsUTF8'))
|
||||
result = run_pip('install', to_install, expect_error=True)
|
||||
result = run_pip('install', to_install, expect_error=True, expect_temp=True, quiet=True)
|
||||
assert '__main__.FakeError: this package designed to fail on install' in result.stdout
|
||||
assert 'UnicodeDecodeError' not in result.stdout
|
||||
|
|
Loading…
Reference in New Issue