From fe2a897abb8a981c2ca1cdae390b50cd3214bfe0 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Wed, 21 Aug 2013 13:34:09 +0200 Subject: fix issue116: make 1.6 introduced behaviour of changing to a per-env HOME directory during install activities dependent on "--set-home" for now. Should re-establish the old behaviour. --- CHANGELOG | 4 ++++ setup.py | 2 +- tests/test_venv.py | 18 ++++++++++++++++++ tox/__init__.py | 2 +- tox/_config.py | 4 ++++ tox/_venv.py | 10 +++++++--- 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e234c46..01ddcfa 100755 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,10 @@ - fix issue119: {envsitepackagesdir} is now correctly computed and has a better test to prevent regression. +- fix issue116: make 1.6 introduced behaviour of changing to a + per-env HOME directory during install activities dependent + on "--set-home" for now. Should re-establish the old behaviour + when no option is given. 1.6.0 ----------------- diff --git a/setup.py b/setup.py index c0f24eb..9994e26 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ def main(): description='virtualenv-based automation of test activities', long_description=open("README.rst").read(), url='http://tox.testrun.org/', - version='1.6.0', + version='1.6.1', license='http://opensource.org/licenses/MIT', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], author='holger krekel', diff --git a/tests/test_venv.py b/tests/test_venv.py index e6792ed..4a03b03 100644 --- a/tests/test_venv.py +++ b/tests/test_venv.py @@ -568,6 +568,24 @@ def test_command_relative_issue26(newmocksession, tmpdir, monkeypatch): x4 = venv.getcommandpath("x", cwd=tmpdir) mocksession.report.expect("warning", "*test command found but not*") +def test_sethome_only_on_option(newmocksession, monkeypatch): + mocksession = newmocksession([], "") + venv = mocksession.getenv('python') + action = mocksession.newaction(venv, "qwe", []) + monkeypatch.setattr(tox._venv, "hack_home_env", None) + venv._install(["x"], action=action) + +def test_sethome_works_on_option(newmocksession, monkeypatch): + mocksession = newmocksession(["--set-home", "-i ALL=http://qwe"], "") + venv = mocksession.getenv('python') + action = mocksession.newaction(venv, "qwe", []) + venv._install(["x"], action=action) + _, mocked = mocksession.report.getnext("logpopen") + p = mocked.env["HOME"] + pydist = py.path.local(p).join(".pydistutils.cfg") + assert "http://qwe" in pydist.read() + + def test_hack_home_env(tmpdir): from tox._venv import hack_home_env env = hack_home_env(tmpdir, "http://index") diff --git a/tox/__init__.py b/tox/__init__.py index f37c663..2aebea5 100644 --- a/tox/__init__.py +++ b/tox/__init__.py @@ -1,5 +1,5 @@ # -__version__ = '1.6.0' +__version__ = '1.6.1' class exception: class Error(Exception): diff --git a/tox/_config.py b/tox/_config.py index a9351d9..c259c42 100644 --- a/tox/_config.py +++ b/tox/_config.py @@ -99,6 +99,10 @@ def prepare_parse(pkgname): parser.add_argument("--develop", action="store_true", dest="develop", help="install package in the venv using 'setup.py develop' via " "'pip -e .'") + parser.add_argument("--set-home", action="store_true", dest="sethome", + help="(experimental) force creating a new $HOME for each test " + "environment and create .pydistutils.cfg|pip.conf files " + "if index servers are specified with tox. ") parser.add_argument('-i', action="append", dest="indexurl", metavar="URL", help="set indexserver url (if URL is of form name=url set the " diff --git a/tox/_venv.py b/tox/_venv.py index d2f2ab3..d67ddb9 100644 --- a/tox/_venv.py +++ b/tox/_venv.py @@ -322,9 +322,13 @@ class VirtualEnv(object): extraopts = extraopts or [] for ixserver in l: - extraenv = hack_home_env( - homedir=self.envconfig.envtmpdir.join("pseudo-home"), - index_url = ixserver.url) + if self.envconfig.config.option.sethome: + extraenv = hack_home_env( + homedir=self.envconfig.envtmpdir.join("pseudo-home"), + index_url = ixserver.url) + else: + extraenv = {} + args = d[ixserver] + extraopts self.run_install_command(args, ixserver.url, action, extraenv=extraenv) -- cgit v1.2.1