summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xCHANGELOG3
-rw-r--r--tests/test_config.py20
-rw-r--r--tests/test_z_cmdline.py7
-rw-r--r--tox/_config.py19
4 files changed, 37 insertions, 12 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 9144b6c..434c720 100755
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,9 @@
- 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)
+
1.6.0
-----------------
diff --git a/tests/test_config.py b/tests/test_config.py
index dd73ba3..969bbba 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("""
@@ -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..cf16b52 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",