summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteffen Allner <sa@gocept.com>2016-06-20 18:13:37 +0200
committerSteffen Allner <sa@gocept.com>2016-06-20 18:13:37 +0200
commit59eeb645f38fff2828a0d9f0c72c4a2d39f638b6 (patch)
tree0bc1ae456c38b164b769bdde75b69c945941eb1a
parent975d9c90c7e0739fa8f9ab79a6ac49dfa722450a (diff)
parentcef9d6b5edf6c40362b0cf40c81201f7092607c4 (diff)
downloadtox-hook/report-status.tar.gz
Merge from defaulthook/report-status
-rw-r--r--CHANGELOG112
-rwxr-xr-xdoc/_getdoctarget.py2
-rw-r--r--doc/config.txt15
-rw-r--r--doc/example/basic.txt3
-rw-r--r--setup.py2
-rw-r--r--tests/test_config.py86
-rw-r--r--tests/test_interpreters.py2
-rw-r--r--tests/test_venv.py13
-rw-r--r--tox.ini10
-rw-r--r--tox/__init__.py8
-rw-r--r--tox/_pytestplugin.py9
-rw-r--r--tox/_quickstart.py2
-rw-r--r--tox/config.py50
-rw-r--r--tox/interpreters.py6
-rw-r--r--tox/result.py6
-rw-r--r--tox/session.py34
16 files changed, 264 insertions, 96 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 81a5803..26447a4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,21 @@
+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
+ something like "pip freeze". Thanks Ted Shaw, Holger Krekel.
+
+- fix issue66, issue121: change install_command to use "python -m pip"
+ by default instead of "pip ..." directly which avoids long shebang
+ issues. If you need to run python2.6 you need to configure it to
+ something like "pip install {opts} {packages}". Thanks Ted Shaw,
+ Holger Krekel.
+
+
2.3.2
-----
@@ -6,6 +24,8 @@
- fix issue279: allow cross-section substitution when the value contains
posargs. Thanks Sachi King for the PR.
+- fix issue317: evaluate minversion before tox config is parsed completely.
+ Thanks Sachi King for the PR.
2.3.1
-----
@@ -20,8 +40,8 @@
devpi system for managing indexes for pip.
- fix issue285: make setenv processing fully lazy to fix regressions
- of tox-2.2.X and so that we can now have testenv attributes like
- "basepython" depend on environment variables that are set in
+ of tox-2.2.X and so that we can now have testenv attributes like
+ "basepython" depend on environment variables that are set in
a setenv section. Thanks Nelfin for some tests and initial
work on a PR.
@@ -34,11 +54,11 @@
- fix issue252: allow environment names with special characters.
Thanks Julien Castets for initial PR and patience.
-- introduce experimental tox_testenv_create(venv, action) and
+- introduce experimental tox_testenv_create(venv, action) and
tox_testenv_install_deps(venv, action) hooks to allow
plugins to do additional work on creation or installing
deps. These hooks are experimental mainly because of
- the involved "venv" and session objects whose current public
+ the involved "venv" and session objects whose current public
API is not fully guranteed.
- internal: push some optional object creation into tests because
@@ -57,18 +77,18 @@
because otherwise the python interpreter might not start up in
certain configurations (redhat software collections). Thanks David Riddle.
-- fix issue246: fix regression in config parsing by reordering
+- fix issue246: fix regression in config parsing by reordering
such that {envbindir} can be used again in tox.ini. Thanks Olli Walsh.
- fix issue99: the {env:...} substitution now properly uses environment
settings from the ``setenv`` section. Thanks Itxaka Serrano.
-- fix issue281: make --force-deps work when urls are present in
+- fix issue281: make --force-dep work when urls are present in
dependency configs. Thanks Glyph Lefkowitz for reporting.
- fix issue174: add new ``ignore_outcome`` testenv attribute which
can be set to True in which case it will produce a warning instead
- of an error on a failed testenv command outcome.
+ of an error on a failed testenv command outcome.
Thanks Rebecka Gulliksson for the PR.
- fix issue280: properly skip missing interpreter if
@@ -85,7 +105,7 @@
2.1.0
----------
-- fix issue258, fix issue248, fix issue253: for non-test commands
+- fix issue258, fix issue248, fix issue253: for non-test commands
(installation, venv creation) we pass in the full invocation environment.
- remove experimental --set-home option which was hardly used and
@@ -106,7 +126,7 @@
2.0.2
----------
-- fix issue247: tox now passes the LANG variable from the tox invocation
+- fix issue247: tox now passes the LANG variable from the tox invocation
environment to the test environment by default.
- add SYSTEMDRIVE into default passenv on windows to allow pip6 to work.
@@ -123,9 +143,9 @@
- (new) introduce environment variable isolation:
tox now only passes the PATH and PIP_INDEX_URL variable from the tox
- invocation environment to the test environment and on Windows
+ invocation environment to the test environment and on Windows
also ``SYSTEMROOT``, ``PATHEXT``, ``TEMP`` and ``TMP`` whereas
- on unix additionally ``TMPDIR`` is passed. If you need to pass
+ on unix additionally ``TMPDIR`` is passed. If you need to pass
through further environment variables you can use the new ``passenv`` setting,
a space-separated list of environment variable names. Each name
can make use of fnmatch-style glob patterns. All environment
@@ -136,9 +156,9 @@
their defaults.
- (new) introduce a way to specify on which platform a testenvironment is to
- execute: the new per-venv "platform" setting allows to specify
+ execute: the new per-venv "platform" setting allows to specify
a regular expression which is matched against sys.platform.
- If platform is set and doesn't match the platform spec in the test
+ If platform is set and doesn't match the platform spec in the test
environment the test environment is ignored, no setup or tests are attempted.
- (new) add per-venv "ignore_errors" setting, which defaults to False.
@@ -169,7 +189,7 @@
See tox/hookspecs.py for the current hooks.
- introduce parser.add_testenv_attribute() to register an ini-variable
- for testenv sections. Can be used from plugins through the
+ for testenv sections. Can be used from plugins through the
tox_add_option hook.
- rename internal files -- tox offers no external API except for the
@@ -182,7 +202,7 @@
1.9.2
-----------
-- backout ability that --force-deps substitutes name/versions in
+- backout ability that --force-dep substitutes name/versions in
requirement files due to various issues.
This fixes issue228, fixes issue230, fixes issue231
which popped up with 1.9.1.
@@ -193,7 +213,7 @@
- use a file instead of a pipe for command output in "--result-json".
Fixes some termination issues with python2.6.
-- allow --force-deps to override dependencies in "-r" requirements
+- allow --force-dep to override dependencies in "-r" requirements
files. Thanks Sontek for the PR.
- fix issue227: use "-m virtualenv" instead of "-mvirtualenv" to make
@@ -208,7 +228,7 @@
dependencies. Use ``pip_pre = true`` in a testenv or the ``--pre``
command-line option to restore the previous behavior.
-- fix issue199: fill resultlog structure ahead of virtualenv creation
+- fix issue199: fill resultlog structure ahead of virtualenv creation
- refine determination if we run from Jenkins, thanks Borge Lanes.
@@ -266,7 +286,7 @@
- fix issue59: add a config variable ``skip-missing-interpreters`` as well as
command line option ``--skip-missing-interpreters`` which won't fail the
- build if Python interpreters listed in tox.ini are missing. Thanks
+ build if Python interpreters listed in tox.ini are missing. Thanks
Alexandre Conrad for PR104.
- fix issue164: better traceback info in case of failing test commands.
@@ -284,29 +304,29 @@
- fix issue162: don't list python 2.5 as compatibiliy/supported
- fix issue158 and fix issue155: windows/virtualenv properly works now:
- call virtualenv through "python -m virtualenv" with the same
+ call virtualenv through "python -m virtualenv" with the same
interpreter which invoked tox. Thanks Chris Withers, Ionel Maries Cristian.
1.7.0
---------
-- don't lookup "pip-script" anymore but rather just "pip" on windows
- as this is a pip implementation detail and changed with pip-1.5.
- It might mean that tox-1.7 is not able to install a different pip
+- don't lookup "pip-script" anymore but rather just "pip" on windows
+ as this is a pip implementation detail and changed with pip-1.5.
+ It might mean that tox-1.7 is not able to install a different pip
version into a virtualenv anymore.
- drop Python2.5 compatibility because it became too hard due
- to the setuptools-2.0 dropping support. tox now has no
+ to the setuptools-2.0 dropping support. tox now has no
support for creating python2.5 based environments anymore
and all internal special-handling has been removed.
-- merged PR81: new option --force-dep which allows to
+- merged PR81: new option --force-dep which allows to
override tox.ini specified dependencies in setuptools-style.
For example "--force-dep 'django<1.6'" will make sure
- that any environment using "django" as a dependency will
- get the latest 1.5 release. Thanks Bruno Oliveria for
+ that any environment using "django" as a dependency will
+ get the latest 1.5 release. Thanks Bruno Oliveria for
the complete PR.
-
+
- merged PR125: tox now sets "PYTHONHASHSEED" to a random value
and offers a "--hashseed" option to repeat a test run with a specific seed.
You can also use --hashsheed=noset to instruct tox to leave the value
@@ -324,9 +344,9 @@
- fix issue130: you can now set install_command=easy_install {opts} {packages}
and expect it to work for repeated tox runs (previously it only worked
- when always recreating). Thanks jenisys for precise reporting.
+ when always recreating). Thanks jenisys for precise reporting.
-- fix issue129: tox now uses Popen(..., universal_newlines=True) to force
+- fix issue129: tox now uses Popen(..., universal_newlines=True) to force
creation of unicode stdout/stderr streams. fixes a problem on specific
platform configs when creating virtualenvs with Python3.3. Thanks
Jorgen Schäfer or investigation and solution sketch.
@@ -344,7 +364,7 @@
requiring networks
- introduce --sitepackages to force sitepackages=True in all
- environments.
+ environments.
- fix issue105 -- don't depend on an existing HOME directory from tox tests.
@@ -354,8 +374,8 @@
- 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
+- 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.
@@ -365,9 +385,9 @@
- 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
+- 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
+ 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.
- fix issue102: change to {toxinidir} when installing dependencies.
@@ -380,11 +400,11 @@
configure the installation command with options for dep/pkg install.
Thanks Carl Meyer for the PR and docs.
-- fix issue91: python2.5 support by vendoring the virtualenv-1.9.1
- script and forcing pip<1.4. Also the default [py25] environment
+- fix issue91: python2.5 support by vendoring the virtualenv-1.9.1
+ script and forcing pip<1.4. Also the default [py25] environment
modifies the default installer_command (new config option)
- to use pip without the "--pre" option which was introduced
- with pip-1.4 and is now required if you want to install non-stable
+ to use pip without the "--pre" option which was introduced
+ with pip-1.4 and is now required if you want to install non-stable
releases. (tox defaults to install with "--pre" everywhere).
- during installation of dependencies HOME is now set to a pseudo
@@ -421,7 +441,7 @@
- fix issue104: use setuptools by default, instead of distribute,
now that setuptools has distribute merged.
-- make sure test commands are searched first in the virtualenv
+- make sure test commands are searched first in the virtualenv
- re-fix issue2 - add whitelist_externals to be used in ``[testenv*]``
sections, allowing to avoid warnings for commands such as ``make``,
@@ -432,12 +452,12 @@
- fix issue92 - fix {envsitepackagesdir} to actually work again
-- show (test) command that is being executed, thanks
+- show (test) command that is being executed, thanks
Lukasz Balcerzak
- re-license tox to MIT license
-- depend on virtualenv-1.9.1
+- depend on virtualenv-1.9.1
- rename README.txt to README.rst to make bitbucket happier
@@ -452,7 +472,7 @@
(thanks Lukasz Balcerzak)
- fix downloadcache determination to work according to docs: Only
- make pip use a download cache if PIP_DOWNLOAD_CACHE or a
+ make pip use a download cache if PIP_DOWNLOAD_CACHE or a
downloadcache=PATH testenv setting is present. (The ENV setting
takes precedence)
@@ -476,7 +496,7 @@
- fix #48 - win32 detection of pypy and other interpreters that are on PATH
(thanks Gustavo Picon)
-- fix grouping of index servers, it is now done by name instead of
+- 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.
@@ -512,7 +532,7 @@
which would formerly raise irritating errors because the ";"
was considered a comment
- tweak and improve reporting
-- refactor reporting and virtualenv manipulation
+- refactor reporting and virtualenv manipulation
to be more accessible from 3rd party tools
- support value substitution from other sections
with the {[section]key} syntax
@@ -527,8 +547,8 @@
1.3
-----------------
-- fix: allow to specify wildcard filesystem paths when
- specifying dependencies such that tox searches for
+- fix: allow to specify wildcard filesystem paths when
+ specifying dependencies such that tox searches for
the highest version
- fix issue issue21: clear PIP_REQUIRES_VIRTUALENV which avoids
diff --git a/doc/_getdoctarget.py b/doc/_getdoctarget.py
index 1199221..f92e87b 100755
--- a/doc/_getdoctarget.py
+++ b/doc/_getdoctarget.py
@@ -13,4 +13,4 @@ def get_minor_version_string():
return ".".join(get_version_string().split(".")[:2])
if __name__ == "__main__":
- print (get_minor_version_string())
+ print(get_minor_version_string())
diff --git a/doc/config.txt b/doc/config.txt
index 205b22a..229f357 100644
--- a/doc/config.txt
+++ b/doc/config.txt
@@ -105,7 +105,20 @@ Complete list of settings that you can put into ``testenv*`` sections:
**default**::
- pip install {opts} {packages}
+ python -m pip install {opts} {packages}
+
+
+.. confval:: list_dependencies_command
+
+ .. versionadded:: 2.4
+
+ the ``list_dependencies_command`` setting is used for listing
+ the packages installed into the virtual environment.
+
+ **default**::
+
+ python -m pip freeze
+
.. confval:: ignore_errors=True|False(default)
diff --git a/doc/example/basic.txt b/doc/example/basic.txt
index 64150f3..84fed34 100644
--- a/doc/example/basic.txt
+++ b/doc/example/basic.txt
@@ -260,8 +260,7 @@ a test run when ``python setup.py test`` is issued::
args = self.tox_args
if args:
args = shlex.split(self.tox_args)
- errno = tox.cmdline(args=args)
- sys.exit(errno)
+ tox.cmdline(args=args)
setup(
#...,
diff --git a/setup.py b/setup.py
index 7662332..2cefdc8 100644
--- a/setup.py
+++ b/setup.py
@@ -48,7 +48,7 @@ def main():
description='virtualenv-based automation of test activities',
long_description=open("README.rst").read(),
url='http://tox.testrun.org/',
- version='2.3.2',
+ version='2.4.0.dev1',
license='http://opensource.org/licenses/MIT',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
author='holger krekel',
diff --git a/tests/test_config.py b/tests/test_config.py
index 372cd4f..08b2f23 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -288,6 +288,20 @@ class TestIniParserAgainstCommandsKey:
x = reader.getargvlist("commands")
assert x == [['thing', 'argpos', 'arg2']]
+ def test_command_section_and_posargs_substitution(self, newconfig):
+ """Ensure subsitition from other section with posargs succeeds"""
+ config = newconfig("""
+ [section]
+ key = thing arg1
+ [testenv]
+ commands =
+ {[section]key} {posargs} endarg
+ """)
+ reader = SectionReader("testenv", config._cfg)
+ reader.addsubstitutions([r"argpos"])
+ x = reader.getargvlist("commands")
+ assert x == [['thing', 'arg1', 'argpos', 'endarg']]
+
def test_command_env_substitution(self, newconfig):
"""Ensure referenced {env:key:default} values are substituted correctly."""
config = newconfig("""
@@ -632,6 +646,55 @@ class TestIniParser:
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("""
@@ -1424,10 +1487,10 @@ class TestGlobalOptions:
def test_minversion(self, tmpdir, newconfig, monkeypatch):
inisource = """
[tox]
- minversion = 3.0
+ minversion = 10.0
"""
- config = newconfig([], inisource)
- assert config.minversion == "3.0"
+ with py.test.raises(tox.exception.MinVersionError):
+ newconfig([], inisource)
def test_skip_missing_interpreters_true(self, tmpdir, newconfig, monkeypatch):
inisource = """
@@ -1851,6 +1914,23 @@ class TestCmdInvocation:
"*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 --git a/tests/test_interpreters.py b/tests/test_interpreters.py
index d2cfa27..c658380 100644
--- a/tests/test_interpreters.py
+++ b/tests/test_interpreters.py
@@ -41,7 +41,7 @@ def test_tox_get_python_executable():
if sys.platform == "win32":
pydir = "python%s" % ver.replace(".", "")
x = py.path.local("c:\%s" % pydir)
- print (x)
+ print(x)
if not x.check():
continue
else:
diff --git a/tests/test_venv.py b/tests/test_venv.py
index 6eb6333..0af9977 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -5,6 +5,7 @@ import os
import sys
import tox.config
from tox.venv import * # noqa
+from tox.hookspecs import hookimpl
from tox.interpreters import NoInterpreterInfo
@@ -137,8 +138,8 @@ def test_install_deps_wildcard(newmocksession):
assert len(l) == 2
args = l[-1].args
assert l[-1].cwd == venv.envconfig.config.toxinidir
- assert "pip" in str(args[0])
- assert args[1] == "install"
+ assert "pip" in str(args[2])
+ assert args[3] == "install"
# arg = "--download-cache=" + str(venv.envconfig.downloadcache)
# assert arg in args[2:]
args = [arg for arg in args if str(arg).endswith("dep1-1.1.zip")]
@@ -167,8 +168,8 @@ def test_install_downloadcache(newmocksession, monkeypatch, tmpdir, envdc):
assert len(l) == 2
args = l[-1].args
assert l[-1].cwd == venv.envconfig.config.toxinidir
- assert "pip" in str(args[0])
- assert args[1] == "install"
+ assert "pip" in str(args)
+ assert args[3] == "install"
assert "dep1" in args
assert "dep2" in args
deps = list(filter(None, [x[1] for x in venv._getliveconfig().deps]))
@@ -365,7 +366,7 @@ def test_install_python3(tmpdir, newmocksession):
venv._install(["hello"], action=action)
assert len(l) == 1
args = l[0].args
- assert 'pip' in str(args[0])
+ assert "pip" in [str(x) for x in args]
for x in args:
assert "--download-cache" not in args, args
@@ -597,7 +598,7 @@ def test_run_install_command(newmocksession):
venv.run_install_command(packages=["whatever"], action=action)
l = mocksession._pcalls
assert len(l) == 1
- assert 'pip' in l[0].args[0]
+ assert 'pip' in l[0].args[2]
assert 'install' in l[0].args
env = l[0].env
assert env is not None
diff --git a/tox.ini b/tox.ini
index 17efc83..a2bbd96 100644
--- a/tox.ini
+++ b/tox.ini
@@ -13,6 +13,13 @@ deps=pytest>=2.3.5
[testenv:py26-bare]
deps =
commands = tox -h
+install_command = pip install {opts} {packages}
+list_dependencies_command = pip freeze
+
+[testenv:py26]
+install_command = pip install {opts} {packages}
+list_dependencies_command = pip freeze
+
[testenv:docs]
basepython=python
@@ -27,7 +34,7 @@ platform=linux
deps = pytest-flakes>=0.2
pytest-pep8
-commands =
+commands =
py.test --flakes -m flakes tox tests
py.test --pep8 -m pep8 tox tests
@@ -53,3 +60,4 @@ pep8maxlinelength = 99
# E731 - do not assign a lambda expression, use a def
pep8ignore =
*.py W503 E402 E731
+flakes-ignore = ImportStarUsage
diff --git a/tox/__init__.py b/tox/__init__.py
index c17341d..baf651b 100644
--- a/tox/__init__.py
+++ b/tox/__init__.py
@@ -1,5 +1,5 @@
#
-__version__ = '2.3.2'
+__version__ = '2.4.0.dev1'
from .hookspecs import hookspec, hookimpl # noqa
@@ -23,5 +23,11 @@ class exception:
""" a directory did not exist. """
class MissingDependency(Error):
""" a dependency could not be found or determined. """
+ class MinVersionError(Error):
+ """ the installed tox version is lower than requested minversion. """
+
+ def __init__(self, message):
+ self.message = message
+ super(exception.MinVersionError, self).__init__(message)
from tox.session import main as cmdline # noqa
diff --git a/tox/_pytestplugin.py b/tox/_pytestplugin.py
index f15d2ec..785070d 100644
--- a/tox/_pytestplugin.py
+++ b/tox/_pytestplugin.py
@@ -68,12 +68,12 @@ class ReportExpectMock:
def generic_report(*args, **kwargs):
self._calls.append((name,) + args)
- print ("%s" % (self._calls[-1], ))
+ print("%s" % (self._calls[-1], ))
return generic_report
def action(self, venv, msg, *args):
self._calls.append(("action", venv, msg))
- print ("%s" % (self._calls[-1], ))
+ print("%s" % (self._calls[-1], ))
return Action(self.session, venv, msg, args)
def getnext(self, cat):
@@ -195,6 +195,9 @@ class Cmd:
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):
+ 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]
assert py.path.local.sysfind(str(argv[0])), argv[0]
p1 = self.tmpdir.join("stdout")
@@ -316,7 +319,7 @@ def initproj(request, tmpdir):
for p in base.visit(lambda x: x.check(file=1)):
manifestlines.append("include %s" % p.relto(base))
create_files(base, {"MANIFEST.in": "\n".join(manifestlines)})
- print ("created project in %s" % (base,))
+ print("created project in %s" % (base,))
base.chdir()
return initproj
diff --git a/tox/_quickstart.py b/tox/_quickstart.py
index a397cb1..59ee48e 100644
--- a/tox/_quickstart.py
+++ b/tox/_quickstart.py
@@ -119,7 +119,7 @@ def do_prompt(d, key, text, default=None, validator=nonempty):
x = term_input(prompt)
if default and not x:
x = default
- if sys.version_info < (3, ) and not isinstance(x, unicode):
+ if sys.version_info < (3, ) and not isinstance(x, unicode): # noqa
# for Python 2.x, try to get a Unicode string out of it
if x.decode('ascii', 'replace').encode('ascii', 'replace') != x:
if TERM_ENCODING:
diff --git a/tox/config.py b/tox/config.py
index 974bbbb..99e678d 100644
--- a/tox/config.py
+++ b/tox/config.py
@@ -12,6 +12,7 @@ import pluggy
import tox.interpreters
from tox import hookspecs
+from tox._verlib import NormalizedVersion
import py
@@ -181,7 +182,7 @@ class PosargsOption:
class InstallcmdOption:
name = "install_command"
type = "argv"
- default = "pip install {opts} {packages}"
+ default = "python -m pip install {opts} {packages}"
help = "install command for dependencies and package under test."
def postprocess(self, testenv_config, value):
@@ -225,7 +226,10 @@ def parseconfig(args=None, plugins=()):
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:
@@ -367,6 +371,9 @@ def tox_addoption(parser):
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")
@@ -518,6 +525,13 @@ def tox_addoption(parser):
help="install package in develop/editable mode")
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")
+
parser.add_testenv_attribute_obj(DepOption())
parser.add_testenv_attribute(
@@ -645,12 +659,18 @@ class parseini:
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")
@@ -665,8 +685,20 @@ class parseini:
reader.addsubstitutions(toxinidir=config.toxinidir,
homedir=config.homedir)
- config.toxworkdir = reader.getpath("toxworkdir", "{toxinidir}/.tox")
+ # 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)
+ if config.minversion:
+ minversion = NormalizedVersion(self.config.minversion)
+ toxversion = NormalizedVersion(tox.__version__)
+ if toxversion < minversion:
+ raise tox.exception.MinVersionError(
+ "tox version is %s, required is at least %s" % (
+ toxversion, minversion))
+ 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 = \
@@ -854,8 +886,12 @@ is_section_substitution = re.compile("{\[[^{}\s]+\]\S+?}").match
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 --git a/tox/interpreters.py b/tox/interpreters.py
index 66e6409..e049f1d 100644
--- a/tox/interpreters.py
+++ b/tox/interpreters.py
@@ -43,10 +43,10 @@ class Interpreters:
try:
res = exec_on_interpreter(info.executable,
[inspect.getsource(sitepackagesdir),
- "print (sitepackagesdir(%r))" % envdir])
+ "print(sitepackagesdir(%r))" % envdir])
except ExecFailed:
val = sys.exc_info()[1]
- print ("execution failed: %s -- %s" % (val.out, val.err))
+ print("execution failed: %s -- %s" % (val.out, val.err))
return ""
else:
return res["dir"]
@@ -56,7 +56,7 @@ def run_and_get_interpreter_info(name, executable):
assert executable
try:
result = exec_on_interpreter(executable,
- [inspect.getsource(pyinfo), "print (pyinfo())"])
+ [inspect.getsource(pyinfo), "print(pyinfo())"])
except ExecFailed:
val = sys.exc_info()[1]
return NoInterpreterInfo(name, executable=val.executable,
diff --git a/tox/result.py b/tox/result.py
index 96ac612..bad8cc3 100644
--- a/tox/result.py
+++ b/tox/result.py
@@ -47,9 +47,9 @@ class EnvLog:
pythonexecutable = py.path.local(pythonexecutable)
out = pythonexecutable.sysexec("-c",
"import sys; "
- "print (sys.executable);"
- "print (list(sys.version_info)); "
- "print (sys.version)")
+ "print(sys.executable);"
+ "print(list(sys.version_info)); "
+ "print(sys.version)")
lines = out.splitlines()
executable = lines.pop(0)
version_info = eval(lines.pop(0))
diff --git a/tox/session.py b/tox/session.py
index 1c9bbef..e29696e 100644
--- a/tox/session.py
+++ b/tox/session.py
@@ -15,7 +15,6 @@ from tox._verlib import NormalizedVersion, IrrationalVersionError
from tox.venv import VirtualEnv
from tox.config import parseconfig
from tox.result import ResultLog
-from tox.hookspecs import hookimpl
from subprocess import STDOUT
@@ -41,6 +40,10 @@ def main(args=None):
raise SystemExit(retcode)
except KeyboardInterrupt:
raise SystemExit(2)
+ except tox.exception.MinVersionError as e:
+ r = Reporter(None)
+ r.error(e.message)
+ raise SystemExit(1)
def show_help(config):
@@ -234,6 +237,12 @@ class Reporter(object):
self._reportedlines = []
# self.cumulated_time = 0.0
+ def _get_verbosity(self):
+ if self.session:
+ return self.session.config.option.verbosity
+ else:
+ return 2
+
def logpopen(self, popen, env):
""" log information about the action.popen() created process. """
cmd = " ".join(map(str, popen.args))
@@ -253,16 +262,17 @@ class Reporter(object):
# self.cumulated_time += duration
self.verbosity2("%s finish: %s after %.2f seconds" % (
action.venvname, action.msg, duration), bold=True)
+ delattr(action, '_starttime')
def startsummary(self):
self.tw.sep("_", "summary")
def info(self, msg):
- if self.session.config.option.verbosity >= 2:
+ if self._get_verbosity() >= 2:
self.logline(msg)
def using(self, msg):
- if self.session.config.option.verbosity >= 1:
+ if self._get_verbosity() >= 1:
self.logline("using %s" % (msg,), bold=True)
def keyboard_interrupt(self):
@@ -298,15 +308,15 @@ class Reporter(object):
self.tw.line("%s" % msg, **opts)
def verbosity0(self, msg, **opts):
- if self.session.config.option.verbosity >= 0:
+ if self._get_verbosity() >= 0:
self.logline("%s" % msg, **opts)
def verbosity1(self, msg, **opts):
- if self.session.config.option.verbosity >= 1:
+ if self._get_verbosity() >= 1:
self.logline("%s" % msg, **opts)
def verbosity2(self, msg, **opts):
- if self.session.config.option.verbosity >= 2:
+ if self._get_verbosity() >= 2:
self.logline("%s" % msg, **opts)
# def log(self, msg):
@@ -364,14 +374,6 @@ class Session:
def runcommand(self):
self.report.using("tox-%s from %s" % (tox.__version__, tox.__file__))
- if self.config.minversion:
- minversion = NormalizedVersion(self.config.minversion)
- toxversion = NormalizedVersion(tox.__version__)
- if toxversion < minversion:
- self.report.error(
- "tox version is %s, required is at least %s" % (
- toxversion, minversion))
- raise SystemExit(1)
if self.config.option.showconfig:
self.showconfig()
elif self.config.option.listenvs:
@@ -539,8 +541,8 @@ class Session:
# write out version dependency information
action = self.newaction(venv, "envreport")
with action:
- pip = venv.getcommandpath("pip")
- output = venv._pcall([str(pip), "freeze"],
+ args = venv.envconfig.list_dependencies_command
+ output = venv._pcall(args,
cwd=self.config.toxinidir,
action=action)
# the output contains a mime-header, skip it