Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #865 from qwcode/no_reuse_build
deal with pre-existing build dirs
- Loading branch information
Showing
8 changed files
with
142 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import os | ||
import tempfile | ||
import shutil | ||
|
||
from pip.exceptions import PreviousBuildDirError | ||
from pip.index import PackageFinder | ||
from pip.req import InstallRequirement, RequirementSet | ||
from tests.test_pip import here, path_to_url, assert_raises_regexp | ||
|
||
find_links = path_to_url(os.path.join(here, 'packages')) | ||
|
||
class TestRequirementSet(object): | ||
"""RequirementSet tests""" | ||
|
||
def setup(self): | ||
self.tempdir = tempfile.mkdtemp() | ||
|
||
def teardown(self): | ||
shutil.rmtree(self.tempdir, ignore_errors=True) | ||
|
||
def basic_reqset(self): | ||
return RequirementSet( | ||
build_dir=os.path.join(self.tempdir, 'build'), | ||
src_dir=os.path.join(self.tempdir, 'src'), | ||
download_dir=None, | ||
download_cache=os.path.join(self.tempdir, 'download_cache'), | ||
) | ||
|
||
def test_no_reuse_existing_build_dir(self): | ||
"""Test prepare_files raise exception with previous build dir""" | ||
|
||
build_dir = os.path.join(self.tempdir, 'build', 'simple') | ||
os.makedirs(build_dir) | ||
open(os.path.join(build_dir, "setup.py"), 'w') | ||
reqset = self.basic_reqset() | ||
req = InstallRequirement.from_line('simple') | ||
reqset.add_requirement(req) | ||
finder = PackageFinder([find_links], []) | ||
assert_raises_regexp( | ||
PreviousBuildDirError, | ||
"pip can't install[\s\S]*%s[\s\S]*%s" % (req, build_dir), | ||
reqset.prepare_files, | ||
finder | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters