[Python-modules-commits] [tox] 01/09: Import tox_2.3.0.orig.tar.gz

Barry Warsaw barry at moszumanska.debian.org
Fri Dec 11 15:05:55 UTC 2015


This is an automated email from the git hooks/post-receive script.

barry pushed a commit to branch master
in repository tox.

commit f378d898feb0b884114c2cd311221527b157c7bb
Author: Barry Warsaw <barry at ubuntu.com>
Date:   Fri Dec 11 09:42:06 2015 -0500

    Import tox_2.3.0.orig.tar.gz
---
 CHANGELOG                |  32 ++++++
 PKG-INFO                 |   2 +-
 doc/Makefile             |   4 +
 doc/_getdoctarget.py     |  16 +++
 doc/conf.py              |  10 +-
 doc/config-v2.txt        |   2 +-
 doc/config.txt           |  15 ++-
 doc/example/basic.txt    |   3 +
 doc/plugins.txt          |   6 ++
 setup.cfg                |   2 +-
 setup.py                 |   2 +-
 tests/test_config.py     | 208 ++++++++++++++++++++++++++-----------
 tests/test_venv.py       | 100 +++++++++++++-----
 tests/test_z_cmdline.py  |  20 +++-
 tox.egg-info/PKG-INFO    |   2 +-
 tox.egg-info/SOURCES.txt |   1 +
 tox.ini                  |   4 +-
 tox/__init__.py          |   2 +-
 tox/_pytestplugin.py     |   9 +-
 tox/config.py            | 261 +++++++++++++++++++++++++++++------------------
 tox/hookspecs.py         |  11 ++
 tox/session.py           |  16 +--
 tox/venv.py              | 104 ++++++++++---------
 23 files changed, 570 insertions(+), 262 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 11ecb1f..a79fe00 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,35 @@
+2.3.0
+-----
+
+- DEPRECATE use of "indexservers" in tox.ini.  It complicates
+  the internal code and it is recommended to rather use the
+  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 
+  a setenv section. Thanks Nelfin for some tests and initial
+  work on a PR.
+
+- allow "#" in commands.  This is slightly incompatible with commands
+  sections that used a comment after a "\" line continuation.
+  Thanks David Stanek for the PR.
+
+- fix issue289: fix build_sphinx target, thanks Barry Warsaw.
+
+- fix issue252: allow environment names with special characters.
+  Thanks Julien Castets for initial PR and patience.
+
+- 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 
+  API is not fully guranteed.
+
+- internal: push some optional object creation into tests because
+  tox core doesn't need it.
+
 2.2.1
 -----
 
diff --git a/PKG-INFO b/PKG-INFO
index c90524b..4d619b5 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: tox
-Version: 2.2.1
+Version: 2.3.0
 Summary: virtualenv-based automation of test activities
 Home-page: http://tox.testrun.org/
 Author: holger krekel
diff --git a/doc/Makefile b/doc/Makefile
index 4ffb98b..aae1962 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -12,6 +12,8 @@ PAPEROPT_a4     = -D latex_paper_size=a4
 PAPEROPT_letter = -D latex_paper_size=letter
 ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
 
+SITETARGET=$(shell ./_getdoctarget.py)
+
 .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
 
 help:
@@ -36,8 +38,10 @@ help:
 clean:
 	-rm -rf $(BUILDDIR)/*
 
+
 install: clean html 
 	@rsync -avz $(BUILDDIR)/html/ testrun.org:/www/testrun.org/tox/latest
+	@rsync -avz $(BUILDDIR)/html/ testrun.org:/www/testrun.org/tox/$(SITETARGET)
 	#dev
     #latexpdf
 	#@scp $(BUILDDIR)/latex/*.pdf testrun.org:www-tox/latest
diff --git a/doc/_getdoctarget.py b/doc/_getdoctarget.py
new file mode 100644
index 0000000..1199221
--- /dev/null
+++ b/doc/_getdoctarget.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+import py
+
+def get_version_string():
+    fn = py.path.local(__file__).join("..", "..",
+                                      "tox", "__init__.py")
+    for line in fn.readlines():
+        if "version" in line and not line.strip().startswith('#'):
+            return eval(line.split("=")[-1])
+
+def get_minor_version_string():
+    return ".".join(get_version_string().split(".")[:2])
+
+if __name__ == "__main__":
+    print (get_minor_version_string())
diff --git a/doc/conf.py b/doc/conf.py
index 79857d7..6094f60 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -13,6 +13,13 @@
 
 import sys, os
 
+# The short X.Y version.
+sys.path.insert(0, os.path.dirname(__file__))
+import _getdoctarget
+
+version = _getdoctarget.get_minor_version_string()
+release = _getdoctarget.get_version_string()
+
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -47,9 +54,6 @@ copyright = u'2015, holger krekel and others'
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
-# The short X.Y version.
-release = "2.2"
-version = "2.2.0"
 # The full version, including alpha/beta/rc tags.
 
 # The language for content autogenerated by Sphinx. Refer to documentation
diff --git a/doc/config-v2.txt b/doc/config-v2.txt
index b621bc1..c639652 100644
--- a/doc/config-v2.txt
+++ b/doc/config-v2.txt
@@ -143,7 +143,7 @@ The new "platform" setting
 
 A testenv can define a new ``platform`` setting.  If its value
 is not contained in the string obtained from calling 
-``platform.platform()`` the environment will be skipped.
+``sys.platform`` the environment will be skipped.
 
 Expanding the ``envlist`` setting
 ----------------------------------------------------------
diff --git a/doc/config.txt b/doc/config.txt
index 8bfa57d..205b22a 100644
--- a/doc/config.txt
+++ b/doc/config.txt
@@ -93,9 +93,6 @@ Complete list of settings that you can put into ``testenv*`` sections:
 
     .. versionadded:: 1.6
 
-    **WARNING**: This setting is **EXPERIMENTAL** so use with care
-    and be ready to adapt your tox.ini's with post-1.6 tox releases.
-
     the ``install_command`` setting is used for installing packages into
     the virtual environment; both the package under test
     and any defined dependencies. Must contain the substitution key
@@ -166,7 +163,8 @@ Complete list of settings that you can put into ``testenv*`` sections:
     package installation.  Each line defines a dependency, which will be
     passed to the installer command for processing.  Each line specifies a file,
     a URL or a package name.  You can additionally specify
-    an :confval:`indexserver` to use for installing this dependency.
+    an :confval:`indexserver` to use for installing this dependency
+    but this functionality is deprecated since tox-2.3.
     All derived dependencies (deps required by the dep) will then be
     retrieved from the specified indexserver::
 
@@ -259,8 +257,9 @@ Complete list of settings that you can put into ``testenv*`` sections:
 
    .. versionadded:: 0.9
 
-   Multi-line ``name = URL`` definitions of python package servers.
-   Dependencies can specify using a specified index server through the
+   (DEPRECATED, will be removed in a future version) Multi-line ``name =
+   URL`` definitions of python package servers.  Dependencies can
+   specify using a specified index server through the
    ``:indexservername:depname`` pattern.  The ``default`` indexserver
    definition determines where unscoped dependencies and the sdist install
    installs from.  Example::
@@ -441,7 +440,7 @@ Values from other sections can be refered to via::
    {[sectionname]valuename}
 
 which you can use to avoid repetition of config values.
-You can put default values in one section and reference them in others to avoid repeting the same values::
+You can put default values in one section and reference them in others to avoid repeating the same values::
 
     [base]
     deps =
@@ -455,7 +454,7 @@ You can put default values in one section and reference them in others to avoid
         {[base]deps}
 
     [testenv:mercurial]
-    dep =
+    deps =
         mercurial
         {[base]deps}
 
diff --git a/doc/example/basic.txt b/doc/example/basic.txt
index d0ad004..64150f3 100644
--- a/doc/example/basic.txt
+++ b/doc/example/basic.txt
@@ -30,6 +30,7 @@ you can run restrict the test run to the python2.6 environment.
 
 Available "default" test environments names are::
 
+    py
     py24
     py25
     py26
@@ -43,6 +44,8 @@ Available "default" test environments names are::
     pypy
     pypy3
 
+The environment ``py`` uses the version of Python used to invoke tox.
+
 However, you can also create your own test environment names,
 see some of the examples in :doc:`examples <../examples>`.
 
diff --git a/doc/plugins.txt b/doc/plugins.txt
index 8e7041c..be3665a 100644
--- a/doc/plugins.txt
+++ b/doc/plugins.txt
@@ -80,3 +80,9 @@ tox hook specifications and related API
 
 .. autoclass:: tox.config.TestenvConfig()
     :members:
+
+.. autoclass:: tox.venv.VirtualEnv()
+    :members:
+
+.. autoclass:: tox.session.Session()
+    :members:
diff --git a/setup.cfg b/setup.cfg
index bec4469..1fb89f9 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
 [build_sphinx]
-source-dir = doc/en/
+source-dir = doc/
 build-dir = doc/build
 all_files = 1
 
diff --git a/setup.py b/setup.py
index a398ade..1f622a2 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.2.1',
+        version='2.3.0',
         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 61047c1..f727a1f 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -283,18 +283,9 @@ class TestIniParserAgainstCommandsKey:
            commands =
              ls {env:TEST}
         """)
-        reader = SectionReader("testenv:py27", config._cfg)
-        x = reader.getargvlist("commands")
-        assert x == [
-            "ls testvalue".split()
-        ]
-        assert x != [
-            "ls {env:TEST}".split()
-        ]
-        y = reader.getargvlist("setenv")
-        assert y == [
-            "TEST=testvalue".split()
-        ]
+        envconfig = config.envconfigs["py27"]
+        assert envconfig.commands == [["ls", "testvalue"]]
+        assert envconfig.setenv["TEST"] == "testvalue"
 
 
 class TestIniParser:
@@ -459,7 +450,7 @@ class TestIniParser:
         config = newconfig("""
             [section]
             key2=
-                cmd1 {item1} \ # a comment
+                cmd1 {item1} \
                      {item2}
         """)
         reader = SectionReader("section", config._cfg)
@@ -474,12 +465,32 @@ class TestIniParser:
         config = newconfig("""
             [section]
             key1=
-                cmd1 'with space' \ # a comment
-                     'after the comment'
+                cmd1 'part one' \
+                     'part two'
+        """)
+        reader = SectionReader("section", config._cfg)
+        x = reader.getargvlist("key1")
+        assert x == [["cmd1", "part one", "part two"]]
+
+    def test_argvlist_comment_after_command(self, tmpdir, newconfig):
+        config = newconfig("""
+            [section]
+            key1=
+                cmd1 --flag  # run the flag on the command
+        """)
+        reader = SectionReader("section", config._cfg)
+        x = reader.getargvlist("key1")
+        assert x == [["cmd1", "--flag"]]
+
+    def test_argvlist_command_contains_hash(self, tmpdir, newconfig):
+        config = newconfig("""
+            [section]
+            key1=
+                cmd1 --re  "use the # symbol for an arg"
         """)
         reader = SectionReader("section", config._cfg)
         x = reader.getargvlist("key1")
-        assert x == [["cmd1", "with space", "after the comment"]]
+        assert x == [["cmd1", "--re", "use the # symbol for an arg"]]
 
     def test_argvlist_positional_substitution(self, tmpdir, newconfig):
         config = newconfig("""
@@ -633,7 +644,7 @@ class TestConfigTestEnv:
         assert envconfig.usedevelop is False
         assert envconfig.ignore_errors is False
         assert envconfig.envlogdir == envconfig.envdir.join("log")
-        assert list(envconfig.setenv.keys()) == ['PYTHONHASHSEED']
+        assert list(envconfig.setenv.definitions.keys()) == ['PYTHONHASHSEED']
         hashseed = envconfig.setenv['PYTHONHASHSEED']
         assert isinstance(hashseed, str)
         # The following line checks that hashseed parses to an integer.
@@ -724,46 +735,6 @@ class TestConfigTestEnv:
         if bp == "jython":
             assert envconfig.envpython == envconfig.envbindir.join(bp)
 
-    def test_setenv_overrides(self, tmpdir, newconfig):
-        config = newconfig("""
-            [testenv]
-            setenv =
-                PYTHONPATH = something
-                ANOTHER_VAL=else
-        """)
-        assert len(config.envconfigs) == 1
-        envconfig = config.envconfigs['python']
-        assert 'PYTHONPATH' in envconfig.setenv
-        assert 'ANOTHER_VAL' in envconfig.setenv
-        assert envconfig.setenv['PYTHONPATH'] == 'something'
-        assert envconfig.setenv['ANOTHER_VAL'] == 'else'
-
-    def test_setenv_with_envdir_and_basepython(self, tmpdir, newconfig):
-        config = newconfig("""
-            [testenv]
-            setenv =
-                VAL = {envdir}
-            basepython = {env:VAL}
-        """)
-        assert len(config.envconfigs) == 1
-        envconfig = config.envconfigs['python']
-        assert 'VAL' in envconfig.setenv
-        assert envconfig.setenv['VAL'] == envconfig.envdir
-        assert envconfig.basepython == envconfig.envdir
-
-    def test_setenv_ordering_1(self, tmpdir, newconfig):
-        config = newconfig("""
-            [testenv]
-            setenv=
-                VAL={envdir}
-            commands=echo {env:VAL}
-        """)
-        assert len(config.envconfigs) == 1
-        envconfig = config.envconfigs['python']
-        assert 'VAL' in envconfig.setenv
-        assert envconfig.setenv['VAL'] == envconfig.envdir
-        assert str(envconfig.envdir) in envconfig.commands[0]
-
     @pytest.mark.parametrize("plat", ["win32", "linux2"])
     def test_passenv_as_multiline_list(self, tmpdir, newconfig, monkeypatch, plat):
         monkeypatch.setattr(sys, "platform", plat)
@@ -1505,7 +1476,7 @@ class TestHashseedOption:
         return envconfigs["python"]
 
     def _check_hashseed(self, envconfig, expected):
-        assert envconfig.setenv == {'PYTHONHASHSEED': expected}
+        assert envconfig.setenv['PYTHONHASHSEED'] == expected
 
     def _check_testenv(self, newconfig, expected, args=None, tox_ini=None):
         envconfig = self._get_envconfig(newconfig, args=args, tox_ini=tox_ini)
@@ -1554,7 +1525,7 @@ class TestHashseedOption:
     def test_noset(self, tmpdir, newconfig):
         args = ['--hashseed', 'noset']
         envconfig = self._get_envconfig(newconfig, args=args)
-        assert envconfig.setenv == {}
+        assert not envconfig.setenv.definitions
 
     def test_noset_with_setenv(self, tmpdir, newconfig):
         tox_ini = """
@@ -1598,6 +1569,125 @@ class TestHashseedOption:
         self._check_hashseed(envconfigs["hash2"], '123456789')
 
 
+class TestSetenv:
+    def test_getdict_lazy(self, tmpdir, newconfig, monkeypatch):
+        monkeypatch.setenv("X", "2")
+        config = newconfig("""
+            [testenv:X]
+            key0 =
+                key1 = {env:X}
+                key2 = {env:Y:1}
+        """)
+        envconfig = config.envconfigs["X"]
+        val = envconfig._reader.getdict_setenv("key0")
+        assert val["key1"] == "2"
+        assert val["key2"] == "1"
+
+    def test_getdict_lazy_update(self, tmpdir, newconfig, monkeypatch):
+        monkeypatch.setenv("X", "2")
+        config = newconfig("""
+            [testenv:X]
+            key0 =
+                key1 = {env:X}
+                key2 = {env:Y:1}
+        """)
+        envconfig = config.envconfigs["X"]
+        val = envconfig._reader.getdict_setenv("key0")
+        d = {}
+        d.update(val)
+        assert d == {"key1": "2", "key2": "1"}
+
+    def test_setenv_uses_os_environ(self, tmpdir, newconfig, monkeypatch):
+        monkeypatch.setenv("X", "1")
+        config = newconfig("""
+            [testenv:env1]
+            setenv =
+                X = {env:X}
+        """)
+        assert config.envconfigs["env1"].setenv["X"] == "1"
+
+    def test_setenv_default_os_environ(self, tmpdir, newconfig, monkeypatch):
+        monkeypatch.delenv("X", raising=False)
+        config = newconfig("""
+            [testenv:env1]
+            setenv =
+                X = {env:X:2}
+        """)
+        assert config.envconfigs["env1"].setenv["X"] == "2"
+
+    def test_setenv_uses_other_setenv(self, tmpdir, newconfig):
+        config = newconfig("""
+            [testenv:env1]
+            setenv =
+                Y = 5
+                X = {env:Y}
+        """)
+        assert config.envconfigs["env1"].setenv["X"] == "5"
+
+    def test_setenv_recursive_direct(self, tmpdir, newconfig):
+        config = newconfig("""
+            [testenv:env1]
+            setenv =
+                X = {env:X:3}
+        """)
+        assert config.envconfigs["env1"].setenv["X"] == "3"
+
+    def test_setenv_overrides(self, tmpdir, newconfig):
+        config = newconfig("""
+            [testenv]
+            setenv =
+                PYTHONPATH = something
+                ANOTHER_VAL=else
+        """)
+        assert len(config.envconfigs) == 1
+        envconfig = config.envconfigs['python']
+        assert 'PYTHONPATH' in envconfig.setenv
+        assert 'ANOTHER_VAL' in envconfig.setenv
+        assert envconfig.setenv['PYTHONPATH'] == 'something'
+        assert envconfig.setenv['ANOTHER_VAL'] == 'else'
+
+    def test_setenv_with_envdir_and_basepython(self, tmpdir, newconfig):
+        config = newconfig("""
+            [testenv]
+            setenv =
+                VAL = {envdir}
+            basepython = {env:VAL}
+        """)
+        assert len(config.envconfigs) == 1
+        envconfig = config.envconfigs['python']
+        assert 'VAL' in envconfig.setenv
+        assert envconfig.setenv['VAL'] == envconfig.envdir
+        assert envconfig.basepython == envconfig.envdir
+
+    def test_setenv_ordering_1(self, tmpdir, newconfig):
+        config = newconfig("""
+            [testenv]
+            setenv=
+                VAL={envdir}
+            commands=echo {env:VAL}
+        """)
+        assert len(config.envconfigs) == 1
+        envconfig = config.envconfigs['python']
+        assert 'VAL' in envconfig.setenv
+        assert envconfig.setenv['VAL'] == envconfig.envdir
+        assert str(envconfig.envdir) in envconfig.commands[0]
+
+    @pytest.mark.xfail(reason="we don't implement cross-section substitution for setenv")
+    def test_setenv_cross_section_subst(self, monkeypatch, newconfig):
+        """test that we can do cross-section substitution with setenv"""
+        monkeypatch.delenv('TEST', raising=False)
+        config = newconfig("""
+            [section]
+            x =
+              NOT_TEST={env:TEST:defaultvalue}
+
+            [testenv]
+            setenv = {[section]x}
+        """)
+        envconfig = config.envconfigs["python"]
+        assert envconfig.setenv["NOT_TEST"] == "defaultvalue"
+
+
 class TestIndexServer:
     def test_indexserver(self, tmpdir, newconfig):
         config = newconfig("""
diff --git a/tests/test_venv.py b/tests/test_venv.py
index b454f5b..4ab3b06 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -56,7 +56,8 @@ def test_create(monkeypatch, mocksession, newconfig):
     venv = VirtualEnv(envconfig, session=mocksession)
     assert venv.path == envconfig.envdir
     assert not venv.path.check()
-    venv.create()
+    action = mocksession.newaction(venv, "getenv")
+    tox_testenv_create(action=action, venv=venv)
     l = mocksession._pcalls
     assert len(l) >= 1
     args = l[0].args
@@ -96,7 +97,8 @@ def test_create_sitepackages(monkeypatch, mocksession, newconfig):
     """)
     envconfig = config.envconfigs['site']
     venv = VirtualEnv(envconfig, session=mocksession)
-    venv.create()
+    action = mocksession.newaction(venv, "getenv")
+    tox_testenv_create(action=action, venv=venv)
     l = mocksession._pcalls
     assert len(l) >= 1
     args = l[0].args
@@ -105,7 +107,8 @@ def test_create_sitepackages(monkeypatch, mocksession, newconfig):
 
     envconfig = config.envconfigs['nosite']
     venv = VirtualEnv(envconfig, session=mocksession)
-    venv.create()
+    action = mocksession.newaction(venv, "getenv")
+    tox_testenv_create(action=action, venv=venv)
     l = mocksession._pcalls
     assert len(l) >= 1
     args = l[0].args
@@ -122,14 +125,15 @@ def test_install_deps_wildcard(newmocksession):
             {distshare}/dep1-*
     """)
     venv = mocksession.getenv("py123")
-    venv.create()
+    action = mocksession.newaction(venv, "getenv")
+    tox_testenv_create(action=action, venv=venv)
     l = mocksession._pcalls
     assert len(l) == 1
     distshare = venv.session.config.distshare
     distshare.ensure("dep1-1.0.zip")
     distshare.ensure("dep1-1.1.zip")
 
-    venv.install_deps()
+    tox_testenv_install_deps(action=action, venv=venv)
     assert len(l) == 2
     args = l[-1].args
     assert l[-1].cwd == venv.envconfig.config.toxinidir
@@ -154,11 +158,12 @@ def test_install_downloadcache(newmocksession, monkeypatch, tmpdir, envdc):
             dep2
     """)
     venv = mocksession.getenv("py123")
-    venv.create()
+    action = mocksession.newaction(venv, "getenv")
+    tox_testenv_create(action=action, venv=venv)
     l = mocksession._pcalls
     assert len(l) == 1
 
-    venv.install_deps()
+    tox_testenv_install_deps(action=action, venv=venv)
     assert len(l) == 2
     args = l[-1].args
     assert l[-1].cwd == venv.envconfig.config.toxinidir
@@ -183,12 +188,13 @@ def test_install_deps_indexserver(newmocksession):
             :abc2:dep3
     """)
     venv = mocksession.getenv('py123')
-    venv.create()
+    action = mocksession.newaction(venv, "getenv")
+    tox_testenv_create(action=action, venv=venv)
     l = mocksession._pcalls
     assert len(l) == 1
     l[:] = []
 
-    venv.install_deps()
+    tox_testenv_install_deps(action=action, venv=venv)
     # two different index servers, two calls
     assert len(l) == 3
     args = " ".join(l[0].args)
@@ -211,12 +217,13 @@ def test_install_deps_pre(newmocksession):
             dep1
     """)
     venv = mocksession.getenv('python')
-    venv.create()
+    action = mocksession.newaction(venv, "getenv")
+    tox_testenv_create(action=action, venv=venv)
     l = mocksession._pcalls
     assert len(l) == 1
     l[:] = []
 
-    venv.install_deps()
+    tox_testenv_install_deps(action=action, venv=venv)
     assert len(l) == 1
     args = " ".join(l[0].args)
     assert "--pre " in args
@@ -246,10 +253,12 @@ def test_install_recreate(newmocksession, tmpdir):
         deps=xyz
     """)
     venv = mocksession.getenv('python')
-    venv.update()
+
+    action = mocksession.newaction(venv, "update")
+    venv.update(action)
     mocksession.installpkg(venv, pkg)
     mocksession.report.expect("verbosity0", "*create*")
-    venv.update()
+    venv.update(action)
     mocksession.report.expect("verbosity0", "*recreate*")
 
 
@@ -263,7 +272,8 @@ def test_test_hashseed_is_in_output(newmocksession):
     finally:
         tox.config.make_hashseed = original_make_hashseed
     venv = mocksession.getenv('python')
-    venv.update()
+    action = mocksession.newaction(venv, "update")
+    venv.update(action)
     venv.test()
     mocksession.report.expect("verbosity0", "python runtests: PYTHONHASHSEED='123456789'")
 
@@ -274,7 +284,8 @@ def test_test_runtests_action_command_is_in_output(newmocksession):
         commands = echo foo bar
     ''')
     venv = mocksession.getenv('python')
-    venv.update()
+    action = mocksession.newaction(venv, "update")
+    venv.update(action)
     venv.test()
     mocksession.report.expect("verbosity0", "*runtests*commands?0? | echo foo bar")
 
@@ -343,7 +354,8 @@ def test_install_python3(tmpdir, newmocksession):
             dep2
     """)
     venv = mocksession.getenv('py123')
-    venv.create()
+    action = mocksession.newaction(venv, "getenv")
+    tox_testenv_create(action=action, venv=venv)
     l = mocksession._pcalls
     assert len(l) == 1
     args = l[0].args
@@ -429,7 +441,8 @@ class TestCreationConfig:
         envconfig = config.envconfigs['python']
         venv = VirtualEnv(envconfig, session=mocksession)
         cconfig = venv._getliveconfig()
-        venv.update()
+        action = mocksession.newaction(venv, "update")
+        venv.update(action)
         assert not venv.path_config.check()
         mocksession.installpkg(venv, pkg)
         assert venv.path_config.check()
@@ -439,36 +452,42 @@ class TestCreationConfig:
         mocksession.report.expect("*", "*create*")
         # modify config and check that recreation happens
         mocksession._clearmocks()
-        venv.update()
+        action = mocksession.newaction(venv, "update")
+        venv.update(action)
         mocksession.report.expect("*", "*reusing*")
         mocksession._clearmocks()
+        action = mocksession.newaction(venv, "update")
         cconfig.python = py.path.local("balla")
         cconfig.writeconfig(venv.path_config)
-        venv.update()
+        venv.update(action)
         mocksession.report.expect("verbosity0", "*recreate*")
 
     def test_dep_recreation(self, newconfig, mocksession):
         config = newconfig([], "")
         envconfig = config.envconfigs['python']
         venv = VirtualEnv(envconfig, session=mocksession)
-        venv.update()
+        action = mocksession.newaction(venv, "update")
+        venv.update(action)
         cconfig = venv._getliveconfig()
         cconfig.deps[:] = [("1" * 32, "xyz.zip")]
         cconfig.writeconfig(venv.path_config)
         mocksession._clearmocks()
-        venv.update()
+        action = mocksession.newaction(venv, "update")
+        venv.update(action)
         mocksession.report.expect("*", "*recreate*")
 
     def test_develop_recreation(self, newconfig, mocksession):
         config = newconfig([], "")
         envconfig = config.envconfigs['python']
         venv = VirtualEnv(envconfig, session=mocksession)
-        venv.update()
+        action = mocksession.newaction(venv, "update")
+        venv.update(action)
         cconfig = venv._getliveconfig()
         cconfig.usedevelop = True
         cconfig.writeconfig(venv.path_config)
         mocksession._clearmocks()
-        venv.update()
+        action = mocksession.newaction(venv, "update")
+        venv.update(action)
         mocksession.report.expect("verbosity0", "*recreate*")
 
 
@@ -481,21 +500,25 @@ class TestVenvTest:
             commands=abc
         """)
         venv = mocksession.getenv("python")
+        action = mocksession.newaction(venv, "getenv")
         monkeypatch.setenv("PATH", "xyz")
         l = []
         monkeypatch.setattr("py.path.local.sysfind", classmethod(
                             lambda *args, **kwargs: l.append(kwargs) or 0 / 0))
 
-        py.test.raises(ZeroDivisionError, "venv._install(list('123'))")
+        with pytest.raises(ZeroDivisionError):
+            venv._install(list('123'), action=action)
         assert l.pop()["paths"] == [venv.envconfig.envbindir]
-        py.test.raises(ZeroDivisionError, "venv.test()")
+        with pytest.raises(ZeroDivisionError):
+            venv.test(action)
         assert l.pop()["paths"] == [venv.envconfig.envbindir]
-        py.test.raises(ZeroDivisionError, "venv.run_install_command(['qwe'])")
+        with pytest.raises(ZeroDivisionError):
+            venv.run_install_command(['qwe'], action=action)
         assert l.pop()["paths"] == [venv.envconfig.envbindir]
         monkeypatch.setenv("PIP_RESPECT_VIRTUALENV", "1")
         monkeypatch.setenv("PIP_REQUIRE_VIRTUALENV", "1")
         monkeypatch.setenv("__PYVENV_LAUNCHER__", "1")
-        py.test.raises(ZeroDivisionError, "venv.run_install_command(['qwe'])")
+        py.test.raises(ZeroDivisionError, "venv.run_install_command(['qwe'], action=action)")
         assert 'PIP_RESPECT_VIRTUALENV' not in os.environ
         assert 'PIP_REQUIRE_VIRTUALENV' not in os.environ
         assert '__PYVENV_LAUNCHER__' not in os.environ
@@ -626,3 +649,26 @@ def test_ignore_outcome_failing_cmd(newmocksession):
     assert venv.status == "ignored failed command"
     mocksession.report.expect("warning", "*command failed but result from "
                                          "testenv is ignored*")
+
+
+def test_tox_testenv_create(newmocksession):
+    l = []
+
+    class Plugin:
+        @hookimpl
+        def tox_testenv_create(self, action, venv):
+            l.append(1)
+
+        @hookimpl
+        def tox_testenv_install_deps(self, action, venv):
+            l.append(2)
+
+    mocksession = newmocksession([], """
+        [testenv]
+        commands=testenv_fail
+        ignore_outcome=True
+    """, plugins=[Plugin()])
+
+    venv = mocksession.getenv('python')
+    venv.update(action=mocksession.newaction(venv, "getenv"))
+    assert l == [1, 2]
diff --git a/tests/test_z_cmdline.py b/tests/test_z_cmdline.py
index 994d4ec..a98d211 100644
--- a/tests/test_z_cmdline.py
+++ b/tests/test_z_cmdline.py
@@ -34,7 +34,8 @@ def test_report_protocol(newconfig):
     report = session.report
     report.expect("using")
     venv = session.getvenv("mypython")
-    venv.update()
+    action = session.newaction(venv, "update")
+    venv.update(action)
     report.expect("logpopen")
 
 
@@ -301,6 +302,23 @@ def test_unknown_dep(cmd, initproj):
     ])
 
 
+def test_venv_special_chars_issue252(cmd, initproj):
+    initproj("pkg123-0.7", filedefs={
+        'tests': {'test_hello.py': "def test_hello(): pass"},
+        'tox.ini': '''
+            [tox]
+            envlist = special&&1
+            [testenv:special&&1]
+            changedir=tests
+        '''
+    })
+    result = cmd.run("tox", )
+    assert result.ret == 0
+    result.stdout.fnmatch_lines([
+        "*installed*pkg123*"
+    ])
+
+
 def test_unknown_environment(cmd, initproj):
     initproj("env123-0.7", filedefs={
         'tox.ini': ''
diff --git a/tox.egg-info/PKG-INFO b/tox.egg-info/PKG-INFO
index c90524b..4d619b5 100644
--- a/tox.egg-info/PKG-INFO
+++ b/tox.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: tox
-Version: 2.2.1
+Version: 2.3.0
 Summary: virtualenv-based automation of test activities
 Home-page: http://tox.testrun.org/
 Author: holger krekel
diff --git a/tox.egg-info/SOURCES.txt b/tox.egg-info/SOURCES.txt
index cefa586..ca911ea 100644
--- a/tox.egg-info/SOURCES.txt
+++ b/tox.egg-info/SOURCES.txt
@@ -8,6 +8,7 @@ setup.cfg
 setup.py
 tox.ini
 doc/Makefile
+doc/_getdoctarget.py
 doc/changelog.txt
 doc/check_sphinx.py
 doc/conf.py
diff --git a/tox.ini b/tox.ini
index d78bcbd..17efc83 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,11 +1,11 @@
 [tox]
-envlist=py27,py26,py34,py33,pypy,flakes,py26-bare
+envlist=py27,py26,py34,py33,py35,pypy,flakes,py26-bare
 
 [testenv:X]
 commands=echo {posargs}
 
 [testenv]
-commands= py.test --timeout=180 {posargs}
+commands= py.test --timeout=180 {posargs:tests}
 
 deps=pytest>=2.3.5
     pytest-timeout
diff --git a/tox/__init__.py b/tox/__init__.py
index c1e74fb..276e330 100644
--- a/tox/__init__.py
+++ b/tox/__init__.py
@@ -1,5 +1,5 @@
 #
-__version__ = '2.2.1'
+__version__ = '2.3.0'
 
 from .hookspecs import hookspec, hookimpl  # noqa
 
diff --git a/tox/_pytestplugin.py b/tox/_pytestplugin.py
index ee85acc..f15d2ec 100644
--- a/tox/_pytestplugin.py
+++ b/tox/_pytestplugin.py
@@ -31,7 +31,7 @@ def pytest_report_header():
 
 @pytest.fixture
 def newconfig(request, tmpdir):
-    def newconfig(args, source=None):
+    def newconfig(args, source=None, plugins=()):
         if source is None:
             source = args
             args = []
@@ -40,7 +40,7 @@ def newconfig(request, tmpdir):
         p.write(s)
         old = tmpdir.chdir()
         try:
-            return parseconfig(args)
+            return parseconfig(args, plugins=plugins)
         finally:
             old.chdir()
     return newconfig
@@ -168,9 +168,8 @@ def newmocksession(request):
     mocksession = request.getfuncargvalue("mocksession")
     newconfig = request.getfuncargvalue("newconfig")
 
-    def newmocksession(args, source):
-        config = newconfig(args, source)
-        mocksession.config = config
+    def newmocksession(args, source, plugins=()):
+        mocksession.config = newconfig(args, source, plugins=plugins)
         return mocksession
     return newmocksession
 
diff --git a/tox/config.py b/tox/config.py
index 9f5aae3..ad80269 100644
--- a/tox/config.py
+++ b/tox/config.py
@@ -26,14 +26,20 @@ for version in '26,27,32,33,34,35,36'.split(','):
 
 hookimpl = pluggy.HookimplMarker("tox")
 
+_dummy = object()
 
-def get_plugin_manager():
+
+def get_plugin_manager(plugins=()):
     # initialize plugin manager
+    import tox.venv
     pm = pluggy.PluginManager("tox")
     pm.add_hookspecs(hookspecs)
     pm.register(tox.config)
     pm.register(tox.interpreters)
+    pm.register(tox.venv)
     pm.load_setuptools_entrypoints("tox")
+    for plugin in plugins:
+        pm.register(plugin)
     pm.check_pending()
     return pm
 
@@ -184,7 +190,7 @@ class InstallcmdOption:
         return value
 
 
-def parseconfig(args=None):
+def parseconfig(args=None, plugins=()):
     """
     :param list[str] args: Optional list of arguments.
     :type pkg: str
@@ -192,7 +198,7 @@ def parseconfig(args=None):
     :raise SystemExit: toxinit file is not found
     """
 
-    pm = get_plugin_manager()
+    pm = get_plugin_manager(plugins)
 
     if args is None:
         args = sys.argv[1:]
@@ -253,6 +259,47 @@ class CountAction(argparse.Action):
             setattr(namespace, self.dest, 0)
 
 
+class SetenvDict:
+    def __init__(self, dict, reader):
+        self.reader = reader
+        self.definitions = dict
+        self.resolved = {}
+        self._lookupstack = []
+
+    def __contains__(self, name):
+        return name in self.definitions
+
+    def get(self, name, default=None):
+        try:
+            return self.resolved[name]
... 622 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/tox.git



More information about the Python-modules-commits mailing list