summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2013-09-04 14:55:13 +0200
committerholger krekel <holger@merlinux.eu>2013-09-04 14:55:13 +0200
commit44a372f509bcc2ce0a251ee2185094bebdf93360 (patch)
tree35822d90ce655e2f72c9aa60e6a410af7aedbda9
parent734b95eafba7160a49eeee60da5e604a43881f6c (diff)
parent42ca139398350d4d61841277a07568e17a6d7b87 (diff)
downloadtox-44a372f509bcc2ce0a251ee2185094bebdf93360.tar.gz
merge
-rwxr-xr-xCHANGELOG8
-rw-r--r--doc/config.txt7
-rw-r--r--tests/test_config.py22
-rw-r--r--tests/test_z_cmdline.py7
-rw-r--r--tox/_config.py25
5 files changed, 49 insertions, 20 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 9144b6c..844b457 100755
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,14 @@
- fix issue118: correctly have two tests use realpath(). Thanks Barry
Warsaw.
+- fix test runs on environments without a home directory
+ (in this case we use toxinidir as the homedir)
+
+- fix issue117: python2.5 fix: don't use ``--insecure`` option because
+ its very existence depends on presence of "ssl". If you
+ want to support python2.5/pip1.3.1 based test environments you need
+ to install ssl and/or use PIP_INSECURE=1 through ``setenv``. section.
+
1.6.0
-----------------
diff --git a/doc/config.txt b/doc/config.txt
index bad9f13..db33373 100644
--- a/doc/config.txt
+++ b/doc/config.txt
@@ -99,10 +99,11 @@ Complete list of settings that you can put into ``testenv*`` sections:
**default on environments using python2.5**::
- pip install --insecure {opts} {packages}``
+ pip install {opts} {packages}``
- (this will use pip<1.4 (so no ``--pre`` option) and python2.5
- typically has no SSL support, therefore ``--insecure``).
+ this will use pip<1.4 which has no ``--pre`` option. Note also
+ that for python2.5 support you may need to install ssl and/or
+ use ``setenv = PIP_INSECURE=1`` in a py25 based testenv.
.. confval:: whitelist_externals=MULTI-LINE-LIST
diff --git a/tests/test_config.py b/tests/test_config.py
index dd73ba3..34c3797 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -73,8 +73,7 @@ class TestConfigPackage:
def test_defaults_distshare(self, tmpdir, newconfig):
config = newconfig([], "")
envconfig = config.envconfigs['python']
- homedir = py.path.local._gethomedir()
- assert config.distshare == homedir.join(".tox", "distshare")
+ assert config.distshare == config.homedir.join(".tox", "distshare")
def test_defaults_changed_dir(self, tmpdir, newconfig):
tmpdir.mkdir("abc").chdir()
@@ -100,6 +99,18 @@ class TestParseconfig:
old.chdir()
assert config.toxinipath == toxinipath
+def test_get_homedir(monkeypatch):
+ monkeypatch.setattr(py.path.local, "_gethomedir",
+ classmethod(lambda x: {}[1]))
+ assert not get_homedir()
+ monkeypatch.setattr(py.path.local, "_gethomedir",
+ classmethod(lambda x: 0/0))
+ assert not get_homedir()
+ monkeypatch.setattr(py.path.local, "_gethomedir",
+ classmethod(lambda x: "123"))
+ assert get_homedir() == "123"
+
+
class TestIniParser:
def test_getdefault_single(self, tmpdir, newconfig):
config = newconfig("""
@@ -498,7 +509,7 @@ class TestConfigTestEnv:
for name in ("x25", "py25-x"):
env = config.envconfigs[name]
assert env.install_command == \
- "pip install --insecure {opts} {packages}".split()
+ "pip install {opts} {packages}".split()
env = config.envconfigs["py26"]
assert env.install_command == \
"pip install --pre {opts} {packages}".split()
@@ -582,7 +593,7 @@ class TestConfigTestEnv:
assert argv[3][0] == conf.envbindir
assert argv[4][0] == conf.envtmpdir
assert argv[5][0] == conf.envpython
- assert argv[6][0] == str(py.path.local._gethomedir())
+ assert argv[6][0] == str(config.homedir)
assert argv[7][0] == config.homedir.join(".tox", "distshare")
assert argv[8][0] == conf.envlogdir
@@ -903,8 +914,7 @@ class TestIndexServer:
pypi = http://pypi.python.org/simple
"""
config = newconfig([], inisource)
- homedir = str(py.path.local._gethomedir())
- expected = "file://%s/.pip/downloads/simple" % homedir
+ expected = "file://%s/.pip/downloads/simple" % config.homedir
assert config.indexserver['default'].url == expected
assert config.indexserver['local1'].url == \
config.indexserver['default'].url
diff --git a/tests/test_z_cmdline.py b/tests/test_z_cmdline.py
index f8fb2ac..343c142 100644
--- a/tests/test_z_cmdline.py
+++ b/tests/test_z_cmdline.py
@@ -625,18 +625,19 @@ def test_installpkg(tmpdir, newconfig):
sdist_path = session.sdist()
assert sdist_path == p
-#@pytest.mark.xfail("sys.platform == 'win32'", reason="test needs better impl")
+@pytest.mark.xfail("sys.platform == 'win32' and sys.version_info < (2,6)",
+ reason="test needs better impl")
def test_envsitepackagesdir(cmd, initproj):
initproj("pkg512-0.0.5", filedefs={
'tox.ini': """
[testenv]
commands=
- python -c "print('X:{envsitepackagesdir}')"
+ python -c "print(r'X:{envsitepackagesdir}')"
"""})
result = cmd.run("tox")
assert result.ret == 0
result.stdout.fnmatch_lines("""
- X:*.tox*python*site-packages*
+ X:*tox*site-packages*
""")
def verify_json_report_format(data, testenvs=True):
diff --git a/tox/_config.py b/tox/_config.py
index c259c42..7939797 100644
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -120,12 +120,19 @@ def prepare_parse(pkgname):
help="additional arguments available to command positional substition")
return parser
-class Config:
+class Config(object):
def __init__(self):
self.envconfigs = {}
self.invocationcwd = py.path.local()
self.interpreters = Interpreters()
+ @property
+ def homedir(self):
+ homedir = get_homedir()
+ if homedir is None:
+ homedir = self.toxinidir # XXX good idea?
+ return homedir
+
class VenvConfig:
def __init__(self, **kw):
self.__dict__.update(kw)
@@ -166,6 +173,12 @@ class VenvConfig:
testenvprefix = "testenv:"
+def get_homedir():
+ try:
+ return py.path.local._gethomedir()
+ except Exception:
+ return None
+
class parseini:
def __init__(self, config, inipath):
config.toxinipath = inipath
@@ -186,9 +199,7 @@ class parseini:
else:
raise ValueError("invalid context")
- config.homedir = py.path.local._gethomedir()
- if config.homedir is None:
- config.homedir = config.toxinidir # XXX good idea?
+
reader.addsubstitions(toxinidir=config.toxinidir,
homedir=config.homedir)
config.toxworkdir = reader.getpath(toxsection, "toxworkdir",
@@ -319,13 +330,11 @@ class parseini:
downloadcache = os.environ.get("PIP_DOWNLOAD_CACHE", downloadcache)
vc.downloadcache = py.path.local(downloadcache)
- # on python 2.5 we can't use "--pre" and we typically
- # need to use --insecure for pip commands because python2.5
- # doesn't support SSL
+ # on pip-1.3.1/python 2.5 we can't use "--pre".
pip_default_opts = ["{opts}", "{packages}"]
info = vc._basepython_info
if info.runnable and info.version_info < (2,6):
- pip_default_opts.insert(0, "--insecure")
+ pass
else:
pip_default_opts.insert(0, "--pre")
vc.install_command = reader.getargv(