summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2012-10-26 13:12:32 +0200
committerholger krekel <holger@merlinux.eu>2012-10-26 13:12:32 +0200
commit22277808cb05996fdf777889e16a0bc3893463e9 (patch)
treee7576484ae6208a7f33b39e7c9c4c4f41683d4e0
parentf13eb0f5f8d8b4ca411f6e54f5bf54e021e4ad93 (diff)
downloadtox-22277808cb05996fdf777889e16a0bc3893463e9.tar.gz
fix issue34 - search tox.ini in parent dirs
-rwxr-xr-xCHANGELOG2
-rw-r--r--tests/test_config.py22
-rw-r--r--tests/test_venv.py1
-rw-r--r--tox/_config.py22
4 files changed, 30 insertions, 17 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 7139179..18608f0 100755
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,8 @@
- fix grouping of index servers, it is now done by name instead of
indexserver url, allowing to use it to separate dependencies
into groups even if using the same default indexserver.
+- look for "tox.ini" files in parent dirs of current dir (closes #34)
+
1.4.2
-----------------
diff --git a/tests/test_config.py b/tests/test_config.py
index 9ad8398..382fc44 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -73,6 +73,18 @@ class TestConfigPackage:
""" % tmpdir)
assert config.toxworkdir == tmpdir
+class TestParseconfig:
+ def test_search_parents(self, tmpdir):
+ from tox._config import parseconfig
+ b = tmpdir.mkdir("a").mkdir("b")
+ toxinipath = tmpdir.ensure("tox.ini")
+ old = b.chdir()
+ try:
+ config = parseconfig([])
+ finally:
+ old.chdir()
+ assert config.toxinipath == toxinipath
+
class TestIniParser:
def test_getdefault_single(self, tmpdir, newconfig):
config = newconfig("""
@@ -763,13 +775,6 @@ class TestCmdInvocation:
assert tox.__version__ in stdout
assert "imported from" in stdout
- def test_unkonwn_ini(self, cmd):
- result = cmd.run("tox")
- assert result.ret
- result.stderr.fnmatch_lines([
- "*tox.ini*does not exist*",
- ])
-
@py.test.mark.xfail("sys.version_info < (2,6)",
reason="virtualenv3 cannot be imported")
def test_config_specific_ini(self, tmpdir, cmd):
@@ -785,10 +790,9 @@ class TestCmdInvocation:
result = cmd.run("tox")
assert result.ret
result.stderr.fnmatch_lines([
- "*ERROR*tox.ini*does not exist*",
+ "*ERROR*tox.ini*not*found*",
])
-
class TestCommandParser:
def test_command_parser_for_word(self):
diff --git a/tests/test_venv.py b/tests/test_venv.py
index 98cb94c..f3023ae 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -15,6 +15,7 @@ from tox._venv import VirtualEnv, CreationConfig, getdigest
def test_getdigest(tmpdir):
assert getdigest(tmpdir) == "0"*32
+@pytest.mark.skipif("sys.platform != 'win32'")
def test_locate_via_py(monkeypatch):
from tox._venv import locate_via_py
class PseudoPy:
diff --git a/tox/_config.py b/tox/_config.py
index 80eb38e..6bb3e4a 100644
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -20,7 +20,17 @@ def parseconfig(args=None, pkg=None):
opts = parser.parse_args(args)
config = Config()
config.option = opts
- parseini(config)
+ basename = config.option.configfile
+ if os.path.isabs(basename):
+ inipath = py.path.local(basename)
+ else:
+ for path in py.path.local().parts(reverse=True):
+ inipath = path.join(basename)
+ if inipath.check():
+ break
+ else:
+ feedback("toxini file %r not found" %(basename), sysexit=True)
+ parseini(config, inipath)
return config
def feedback(msg, sysexit=False):
@@ -57,7 +67,7 @@ def prepare_parse(pkgname):
help="show configuration information. ")
parser.add_argument("-c", action="store", default="tox.ini",
dest="configfile",
- help="use the specified config file.")
+ help="use the specified config file name.")
parser.add_argument("-e", action="store", dest="env",
metavar="envlist",
help="work against specified environments (ALL selects all).")
@@ -103,14 +113,10 @@ class VenvConfig:
testenvprefix = "testenv:"
class parseini:
- def __init__(self, config):
- config.option.configfile = py.path.local(config.option.configfile)
- config.toxinipath = config.option.configfile
+ def __init__(self, config, inipath):
+ config.toxinipath = inipath
config.toxinidir = toxinidir = config.toxinipath.dirpath()
- if not config.toxinipath.check():
- feedback("toxini file %r does not exist" %(
- str(config.toxinipath)), sysexit=True)
self._cfg = py.iniconfig.IniConfig(config.toxinipath)
config._cfg = self._cfg
self.config = config