[Pytest-commit] commit/tox: 4 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Jun 20 11:41:04 EDT 2016
4 new commits in tox:
https://bitbucket.org/hpk42/tox/commits/a0ee20aeee1a/
Changeset: a0ee20aeee1a
User: danring
Date: 2015-12-17 20:44:22+00:00
Summary: Add --workdir to override the 'toxworkdir' config option
Affected #: 1 file
diff -r 2d5d0e7584cc4cc35cc7e0519ce9610dd52b7a62 -r a0ee20aeee1a0b458e1804290cdd6dbda2bf8313 tox/config.py
--- a/tox/config.py
+++ b/tox/config.py
@@ -366,6 +366,9 @@
help="override sitepackages setting to True in all envs")
parser.add_argument("--skip-missing-interpreters", action="store_true",
help="don't fail tests for missing interpreters")
+ parser.add_argument("--workdir", action="store",
+ dest="workdir", metavar="PATH", default=None,
+ help="tox working directory")
parser.add_argument("args", nargs="*",
help="additional arguments available to command positional substitution")
@@ -664,7 +667,10 @@
reader.addsubstitutions(toxinidir=config.toxinidir,
homedir=config.homedir)
- config.toxworkdir = reader.getpath("toxworkdir", "{toxinidir}/.tox")
+ if config.option.workdir is None:
+ config.toxworkdir = reader.getpath("toxworkdir", "{toxinidir}/.tox")
+ else:
+ config.toxworkdir = config.toxinidir.join(config.option.workdir, abs=True)
config.minversion = reader.getstring("minversion", None)
if not config.option.skip_missing_interpreters:
https://bitbucket.org/hpk42/tox/commits/fe3f43b80f63/
Changeset: fe3f43b80f63
User: danring
Date: 2015-12-17 20:44:52+00:00
Summary: Add test for --workdir command line option
Affected #: 1 file
diff -r a0ee20aeee1a0b458e1804290cdd6dbda2bf8313 -r fe3f43b80f6309d739fd000c2320ca2f4a0b2f1b tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -1837,6 +1837,23 @@
"*ERROR*tox.ini*not*found*",
])
+ def test_override_workdir(self, tmpdir, cmd, initproj):
+ baddir = "badworkdir-123"
+ gooddir = "overridden-234"
+ initproj("overrideworkdir-0.5", filedefs={
+ 'tox.ini': '''
+ [tox]
+ toxworkdir=%s
+ ''' % baddir,
+ })
+ result = cmd.run("tox", "--workdir", gooddir, "--showconfig")
+ assert not result.ret
+ stdout = result.stdout.str()
+ assert gooddir in stdout
+ assert baddir not in stdout
+ assert py.path.local(gooddir).check()
+ assert not py.path.local(baddir).check()
+
def test_showconfig_with_force_dep_version(self, cmd, initproj):
initproj('force_dep_version', filedefs={
'tox.ini': '''
https://bitbucket.org/hpk42/tox/commits/6fc76acddcf0/
Changeset: 6fc76acddcf0
User: hpk42
Date: 2016-06-20 15:38:24+00:00
Summary: add --workdir option to override where tox stores its ".tox" directory
and all of the virtualenv environment. Thanks Danring.
Affected #: 3 files
diff -r 1503c3a65bc8035d091155fcf410cf24d07dd677 -r 6fc76acddcf099546473bfd61feb6d0bbbf2c0d7 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
2.4.0
-----
+- add --workdir option to override where tox stores its ".tox" directory
+ and all of the virtualenv environment. Thanks Danring.
+
- introduce per-venv list_dependencies_command which defaults
to "python -m pip freeze" to obtain the list of installed packages.
If you need to run python2.6 you need to configure it to
diff -r 1503c3a65bc8035d091155fcf410cf24d07dd677 -r 6fc76acddcf099546473bfd61feb6d0bbbf2c0d7 tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -1865,6 +1865,23 @@
"*ERROR*tox.ini*not*found*",
])
+ def test_override_workdir(self, tmpdir, cmd, initproj):
+ baddir = "badworkdir-123"
+ gooddir = "overridden-234"
+ initproj("overrideworkdir-0.5", filedefs={
+ 'tox.ini': '''
+ [tox]
+ toxworkdir=%s
+ ''' % baddir,
+ })
+ result = cmd.run("tox", "--workdir", gooddir, "--showconfig")
+ assert not result.ret
+ stdout = result.stdout.str()
+ assert gooddir in stdout
+ assert baddir not in stdout
+ assert py.path.local(gooddir).check()
+ assert not py.path.local(baddir).check()
+
def test_showconfig_with_force_dep_version(self, cmd, initproj):
initproj('force_dep_version', filedefs={
'tox.ini': '''
diff -r 1503c3a65bc8035d091155fcf410cf24d07dd677 -r 6fc76acddcf099546473bfd61feb6d0bbbf2c0d7 tox/config.py
--- a/tox/config.py
+++ b/tox/config.py
@@ -367,6 +367,9 @@
help="override sitepackages setting to True in all envs")
parser.add_argument("--skip-missing-interpreters", action="store_true",
help="don't fail tests for missing interpreters")
+ parser.add_argument("--workdir", action="store",
+ dest="workdir", metavar="PATH", default=None,
+ help="tox working directory")
parser.add_argument("args", nargs="*",
help="additional arguments available to command positional substitution")
@@ -675,7 +678,6 @@
# As older versions of tox may have bugs or incompatabilities that
# prevent parsing of tox.ini this must be the first thing checked.
config.minversion = reader.getstring("minversion", None)
- # Parse our compatability immediately
if config.minversion:
minversion = NormalizedVersion(self.config.minversion)
toxversion = NormalizedVersion(tox.__version__)
@@ -683,7 +685,10 @@
raise tox.exception.MinVersionError(
"tox version is %s, required is at least %s" % (
toxversion, minversion))
- config.toxworkdir = reader.getpath("toxworkdir", "{toxinidir}/.tox")
+ if config.option.workdir is None:
+ config.toxworkdir = reader.getpath("toxworkdir", "{toxinidir}/.tox")
+ else:
+ config.toxworkdir = config.toxinidir.join(config.option.workdir, abs=True)
if not config.option.skip_missing_interpreters:
config.option.skip_missing_interpreters = \
https://bitbucket.org/hpk42/tox/commits/bb377f12d053/
Changeset: bb377f12d053
User: hpk42
Date: 2016-06-20 15:40:38+00:00
Summary: merge
Affected #: 5 files
diff -r 6fc76acddcf099546473bfd61feb6d0bbbf2c0d7 -r bb377f12d053fb136deb0ba973f2444385acf233 tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -646,6 +646,55 @@
py.test.raises(tox.exception.ConfigError, 'reader.getbool("key5")')
+class TestIniParserPrefix:
+ def test_basic_section_access(self, tmpdir, newconfig):
+ config = newconfig("""
+ [p:section]
+ key=value
+ """)
+ reader = SectionReader("section", config._cfg, prefix="p")
+ x = reader.getstring("key")
+ assert x == "value"
+ assert not reader.getstring("hello")
+ x = reader.getstring("hello", "world")
+ assert x == "world"
+
+ def test_fallback_sections(self, tmpdir, newconfig):
+ config = newconfig("""
+ [p:mydefault]
+ key2=value2
+ [p:section]
+ key=value
+ """)
+ reader = SectionReader("section", config._cfg, prefix="p",
+ fallbacksections=['p:mydefault'])
+ x = reader.getstring("key2")
+ assert x == "value2"
+ x = reader.getstring("key3")
+ assert not x
+ x = reader.getstring("key3", "world")
+ assert x == "world"
+
+ def test_value_matches_prefixed_section_substituion(self):
+ assert is_section_substitution("{[p:setup]commands}")
+
+ def test_value_doesn_match_prefixed_section_substitution(self):
+ assert is_section_substitution("{[p: ]commands}") is None
+ assert is_section_substitution("{[p:setup]}") is None
+ assert is_section_substitution("{[p:setup] commands}") is None
+
+ def test_other_section_substitution(self, newconfig):
+ config = newconfig("""
+ [p:section]
+ key = rue
+ [p:testenv]
+ key = t{[p:section]key}
+ """)
+ reader = SectionReader("testenv", config._cfg, prefix="p")
+ x = reader.getstring("key")
+ assert x == "true"
+
+
class TestConfigTestEnv:
def test_commentchars_issue33(self, tmpdir, newconfig):
config = newconfig("""
@@ -1441,7 +1490,7 @@
minversion = 10.0
"""
with py.test.raises(tox.exception.MinVersionError):
- config = newconfig([], inisource)
+ newconfig([], inisource)
def test_skip_missing_interpreters_true(self, tmpdir, newconfig, monkeypatch):
inisource = """
diff -r 6fc76acddcf099546473bfd61feb6d0bbbf2c0d7 -r bb377f12d053fb136deb0ba973f2444385acf233 tox.ini
--- a/tox.ini
+++ b/tox.ini
@@ -34,7 +34,7 @@
deps = pytest-flakes>=0.2
pytest-pep8
-commands =
+commands =
py.test --flakes -m flakes tox tests
py.test --pep8 -m pep8 tox tests
@@ -60,3 +60,4 @@
# E731 - do not assign a lambda expression, use a def
pep8ignore =
*.py W503 E402 E731
+flakes-ignore = ImportStarUsage
diff -r 6fc76acddcf099546473bfd61feb6d0bbbf2c0d7 -r bb377f12d053fb136deb0ba973f2444385acf233 tox/_pytestplugin.py
--- a/tox/_pytestplugin.py
+++ b/tox/_pytestplugin.py
@@ -195,7 +195,7 @@
return py.std.subprocess.Popen(argv, stdout=stdout, stderr=stderr, **kw)
def run(self, *argv):
- if argv[0] == "tox" and sys.version_info[:2] < (2,7):
+ if argv[0] == "tox" and sys.version_info[:2] < (2, 7):
pytest.skip("can not run tests involving calling tox on python2.6. "
"(and python2.6 is about to be deprecated anyway)")
argv = [str(x) for x in argv]
diff -r 6fc76acddcf099546473bfd61feb6d0bbbf2c0d7 -r bb377f12d053fb136deb0ba973f2444385acf233 tox/config.py
--- a/tox/config.py
+++ b/tox/config.py
@@ -225,7 +225,10 @@
if inipath.check():
break
else:
- feedback("toxini file %r not found" % (basename), sysexit=True)
+ inipath = py.path.local().join('setup.cfg')
+ if not inipath.check():
+ feedback("toxini file %r not found" % (basename), sysexit=True)
+
try:
parseini(config, inipath)
except tox.exception.InterpreterNotFound:
@@ -523,10 +526,10 @@
parser.add_testenv_attribute_obj(InstallcmdOption())
parser.add_testenv_attribute(
- name = "list_dependencies_command",
- type = "argv",
- default = "python -m pip freeze",
- help = "list dependencies for a virtual environment")
+ name="list_dependencies_command",
+ type="argv",
+ default="python -m pip freeze",
+ help="list dependencies for a virtual environment")
parser.add_testenv_attribute_obj(DepOption())
@@ -655,12 +658,18 @@
self._cfg = py.iniconfig.IniConfig(config.toxinipath)
config._cfg = self._cfg
self.config = config
+
+ if inipath.basename == 'setup.cfg':
+ prefix = 'tox'
+ else:
+ prefix = None
ctxname = getcontextname()
if ctxname == "jenkins":
- reader = SectionReader("tox:jenkins", self._cfg, fallbacksections=['tox'])
+ reader = SectionReader("tox:jenkins", self._cfg, prefix=prefix,
+ fallbacksections=['tox'])
distshare_default = "{toxworkdir}/distshare"
elif not ctxname:
- reader = SectionReader("tox", self._cfg)
+ reader = SectionReader("tox", self._cfg, prefix=prefix)
distshare_default = "{homedir}/.tox/distshare"
else:
raise ValueError("invalid context")
@@ -876,8 +885,12 @@
class SectionReader:
- def __init__(self, section_name, cfgparser, fallbacksections=None, factors=()):
- self.section_name = section_name
+ def __init__(self, section_name, cfgparser, fallbacksections=None,
+ factors=(), prefix=None):
+ if prefix is None:
+ self.section_name = section_name
+ else:
+ self.section_name = "%s:%s" % (prefix, section_name)
self._cfg = cfgparser
self.fallbacksections = fallbacksections or []
self.factors = factors
diff -r 6fc76acddcf099546473bfd61feb6d0bbbf2c0d7 -r bb377f12d053fb136deb0ba973f2444385acf233 tox/session.py
--- a/tox/session.py
+++ b/tox/session.py
@@ -537,7 +537,6 @@
# write out version dependency information
action = self.newaction(venv, "envreport")
with action:
- python = venv.getcommandpath("python")
args = venv.envconfig.list_dependencies_command
output = venv._pcall(args,
cwd=self.config.toxinidir,
Repository URL: https://bitbucket.org/hpk42/tox/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list