1. holger krekel
  2. tox

Commits

holger krekel  committed 4949def

extend pseudo-homedir with .pip/pip.conf so that any "pip" command
triggered by tests (such as tox' tests itself) will pick it up.

  • Participants
  • Parent commits 394c743
  • Branches default

Comments (0)

Files changed (2)

File tests/test_venv.py

View file
  • Ignore whitespace
     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()

File tox/_venv.py

View file
  • Ignore whitespace
             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
     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