summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2013-08-15 13:00:26 +0200
committerholger krekel <holger@merlinux.eu>2013-08-15 13:00:26 +0200
commit4b82018b3ed3008a5a00787ece4697fc5ab477fa (patch)
treee6835104e7ed20e16483a38ebeb182c127f911d7
parent57d104e109a9b9c3a3daf147a769e63d92e6bd2b (diff)
downloadtox-4b82018b3ed3008a5a00787ece4697fc5ab477fa.tar.gz
extend pseudo-homedir with .pip/pip.conf so that any "pip" command
triggered by tests (such as tox' tests itself) will pick it up.
-rw-r--r--tests/test_venv.py12
-rw-r--r--tox/_venv.py5
2 files changed, 16 insertions, 1 deletions
diff --git a/tests/test_venv.py b/tests/test_venv.py
index aed5487..52acc95 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -632,3 +632,15 @@ def test_hack_home_env(tmpdir):
assert env["HOME"] == str(tmpdir)
assert not tmpdir.join(".pydistutils.cfg").check()
assert "PIP_INDEX_URL" not in env
+
+def test_hack_home_env_passthrough(tmpdir, monkeypatch):
+ from tox._venv import hack_home_env
+ env = hack_home_env(tmpdir, "http://index")
+ monkeypatch.setattr(os, "environ", env)
+
+ tmpdir = tmpdir.mkdir("tmpdir2")
+ env2 = hack_home_env(tmpdir)
+ assert env2["HOME"] == str(tmpdir)
+ assert env2["PIP_INDEX_URL"] == "http://index"
+ assert "index_url = http://index" in \
+ tmpdir.join(".pydistutils.cfg").read()
diff --git a/tox/_venv.py b/tox/_venv.py
index b43138a..b8f2daf 100644
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -457,7 +457,7 @@ else:
locate_via_py(*m.groups())
-def hack_home_env(homedir, index_url):
+def hack_home_env(homedir, index_url=None):
# XXX HACK (this could also live with tox itself, consider)
# if tox uses pip on a package that requires setup_requires
# the index url set with pip is usually not recognized
@@ -468,9 +468,12 @@ def hack_home_env(homedir, index_url):
if not homedir.check():
homedir.ensure(dir=1)
d = dict(HOME=str(homedir))
+ if not index_url:
+ index_url = os.environ.get("TOX_INDEX_URL")
if index_url:
homedir.join(".pydistutils.cfg").write(
"[easy_install]\n"
"index_url = %s\n" % index_url)
d["PIP_INDEX_URL"] = index_url
+ d["TOX_INDEX_URL"] = index_url
return d