[Pytest-commit] commit/tox: 3 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Aug 8 11:41:58 CEST 2013


3 new commits in tox:

https://bitbucket.org/hpk42/tox/commits/babdb9c26786/
Changeset:   babdb9c26786
User:        Anthon van der Neut
Date:        2013-08-08 09:41:18
Summary:     dash_e: fixes #109 and #111

Behaviour of -e has not changed, but can be set by passing True or False
as a parameter multi_dash_e to tox/_config.py: prepare_parse()

This parameter should come from a user specifyable default value
for backwards compatibility. Default should preferable be True after
that is implemented.

_split_env() was factored out of class parseini to enable testing

The issue #111: error on specifying same env twice ("tox -e py27,py27")
fixed. Multiple specifications of the same environment result in
multiple invocation (this could also be selectable in a
configuration file)
Affected #:  3 files

diff -r c44e2c27e2e09e71ab9270c15333baa1333502df -r babdb9c26786160c2cfbfdc9759e9fb86de5c0c9 tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -7,6 +7,7 @@
 import py
 from tox._config import IniReader, CommandParser
 from tox._config import parseconfig
+from tox._config import prepare_parse, _split_env
 
 class TestVenvConfig:
     def test_config_parsing_minimal(self, tmpdir, newconfig):
@@ -927,6 +928,42 @@
             "*ERROR*tox.ini*not*found*",
         ])
 
+
+class TestArgumentParser:
+
+    def test_dash_e_silent1(self):
+        parser = prepare_parse('testpkg', None)
+        args = parser.parse_args('-e py26 -e py33'.split())
+        envlist = _split_env(args.env)
+        assert envlist == ['py33']
+
+    def test_dash_e_silent2(self):
+        parser = prepare_parse('testpkg', None)
+        args = parser.parse_args('-e py26,py33'.split())
+        envlist = _split_env(args.env)
+        assert envlist == ['py26', 'py33']
+
+    def test_dash_e_silent3(self):
+        parser = prepare_parse('testpkg', None)
+        args = parser.parse_args('-e py26,py26'.split())
+        envlist = _split_env(args.env)
+        assert envlist == ['py26', 'py26']
+
+    def test_dash_e_warn(self, capsys):
+        parser = prepare_parse('testpkg', False)
+        args = parser.parse_args('-e py26,py32 -e py33'.split())
+        envlist = _split_env(args.env)
+        out, err = capsys.readouterr()
+        assert 'WARNING: previous optional argument "-e py26' in out
+        assert envlist == ['py33']
+
+    def test_dash_e_combine(self):
+        parser = prepare_parse('testpkg', True)
+        args = parser.parse_args('-e py26,py25,py33 -e py33,py27'.split())
+        envlist = _split_env(args.env)
+        assert envlist == ['py26', 'py25', 'py33', 'py33', 'py27']
+
+
 class TestCommandParser:
 
     def test_command_parser_for_word(self):

diff -r c44e2c27e2e09e71ab9270c15333baa1333502df -r babdb9c26786160c2cfbfdc9759e9fb86de5c0c9 tox/_config.py
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -66,7 +66,25 @@
         else:
             setattr(namespace, self.dest, 0)
 
-def prepare_parse(pkgname):
+class CheckSingleStoreAction(argparse.Action):
+    """issue a warning when the store action is called multiple times"""
+    def __call__(self, parser, namespace, values, option_string=None):
+        if getattr(namespace, self.dest, None) is not None:
+            py.builtin.print_(
+                'WARNING: previous optional argument "' + option_string + " " +
+                getattr(namespace, self.dest) + '" overwritten by "' +
+                option_string + " " + values + '"')
+        setattr(namespace, self.dest, values)
+
+
+def prepare_parse(pkgname, multi_dash_e=None):
+    """setup ArgumentParser
+
+    multi_dash_e:
+        None -> silently ignore all but last -e pyXY option (old behaviour
+        False -> take last -e pyXY option, but warn on sys.stdout
+        True -> concatenate
+    """
     parser = argparse.ArgumentParser(description=__doc__,)
         #formatter_class=argparse.ArgumentDefaultsHelpFormatter)
     parser.pkgname = pkgname
@@ -83,7 +101,13 @@
     parser.add_argument("-c", action="store", default="tox.ini",
         dest="configfile",
         help="use the specified config file name.")
-    parser.add_argument("-e", action="store", dest="env",
+    if multi_dash_e is None:
+        dash_e_action = "store"
+    elif multi_dash_e is False:
+        dash_e_action = CheckSingleStoreAction
+    elif multi_dash_e is True:
+        dash_e_action = "append"
+    parser.add_argument("-e", action=dash_e_action, dest="env",
         metavar="envlist",
         help="work against specified environments (ALL selects all).")
     parser.add_argument("--notest", action="store_true", dest="notest",
@@ -346,9 +370,21 @@
             envlist = list(self.config.envconfigs)
             envlist.sort()
         else:
-            envlist = env.split(",")
+            envlist = _split_env(env)
         return envlist
 
+def _split_env(env):
+    """if handed a list, action="append" was used for -e """
+    envlist = []
+    if not isinstance(env, list):
+        env = [env]
+    for to_split in env:
+        for single_env in to_split.split(","):
+            # "remove True or", if not allowing multiple same runs, update tests
+            if True or single_env not in envlist:
+                envlist.append(single_env)
+    return envlist
+
 class DepConfig:
     def __init__(self, name, indexserver=None):
         self.name = name

diff -r c44e2c27e2e09e71ab9270c15333baa1333502df -r babdb9c26786160c2cfbfdc9759e9fb86de5c0c9 tox/_venv.py
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -325,7 +325,10 @@
             self.session.make_emptydir(self.envconfig.envtmpdir)
             cwd = self.envconfig.changedir
             for i, argv in enumerate(self.envconfig.commands):
-                message = "commands[%s] | %s" % (i, ' '.join(argv))
+                # have to make strings as _pcall changes argv[0] to a local()
+                # happens if the same environment is invoked twice
+                message = "commands[%s] | %s" % (i, ' '.join(
+                    [str(x) for x in argv]))
                 action.setactivity("runtests", message)
                 try:
                     self._pcall(argv, cwd=cwd, action=action, redirect=redirect)


https://bitbucket.org/hpk42/tox/commits/96e1ba41e1c0/
Changeset:   96e1ba41e1c0
User:        Anthon van der Neut
Date:        2013-08-08 11:29:48
Summary:     dash_e: fixes #109 and #111

Behaviour of -e has not changed, but can be set by passing True or False
as a parameter multi_dash_e to tox/_config.py: prepare_parse()

This parameter should come from a user specifyable default value
for backwards compatibility. Default should preferable be True after
that is implemented.

_split_env() was factored out of class parseini to enable testing

The issue #111: error on specifying same env twice ("tox -e py27,py27")
fixed. Multiple specifications of the same environment result in
multiple invocation (this could also be selectable in a
configuration file)
Affected #:  2 files

diff -r babdb9c26786160c2cfbfdc9759e9fb86de5c0c9 -r 96e1ba41e1c080148fe8baf5c03ba27febd2a330 tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -931,34 +931,26 @@
 
 class TestArgumentParser:
 
-    def test_dash_e_silent1(self):
-        parser = prepare_parse('testpkg', None)
-        args = parser.parse_args('-e py26 -e py33'.split())
+    def test_dash_e_single_1(self):
+        parser = prepare_parse('testpkg')
+        args = parser.parse_args('-e py26'.split())
         envlist = _split_env(args.env)
-        assert envlist == ['py33']
+        assert envlist == ['py26']
 
-    def test_dash_e_silent2(self):
-        parser = prepare_parse('testpkg', None)
+    def test_dash_e_single_2(self):
+        parser = prepare_parse('testpkg')
         args = parser.parse_args('-e py26,py33'.split())
         envlist = _split_env(args.env)
         assert envlist == ['py26', 'py33']
 
-    def test_dash_e_silent3(self):
-        parser = prepare_parse('testpkg', None)
+    def test_dash_e_same(self):
+        parser = prepare_parse('testpkg')
         args = parser.parse_args('-e py26,py26'.split())
         envlist = _split_env(args.env)
         assert envlist == ['py26', 'py26']
 
-    def test_dash_e_warn(self, capsys):
-        parser = prepare_parse('testpkg', False)
-        args = parser.parse_args('-e py26,py32 -e py33'.split())
-        envlist = _split_env(args.env)
-        out, err = capsys.readouterr()
-        assert 'WARNING: previous optional argument "-e py26' in out
-        assert envlist == ['py33']
-
     def test_dash_e_combine(self):
-        parser = prepare_parse('testpkg', True)
+        parser = prepare_parse('testpkg')
         args = parser.parse_args('-e py26,py25,py33 -e py33,py27'.split())
         envlist = _split_env(args.env)
         assert envlist == ['py26', 'py25', 'py33', 'py33', 'py27']

diff -r babdb9c26786160c2cfbfdc9759e9fb86de5c0c9 -r 96e1ba41e1c080148fe8baf5c03ba27febd2a330 tox/_config.py
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -66,18 +66,7 @@
         else:
             setattr(namespace, self.dest, 0)
 
-class CheckSingleStoreAction(argparse.Action):
-    """issue a warning when the store action is called multiple times"""
-    def __call__(self, parser, namespace, values, option_string=None):
-        if getattr(namespace, self.dest, None) is not None:
-            py.builtin.print_(
-                'WARNING: previous optional argument "' + option_string + " " +
-                getattr(namespace, self.dest) + '" overwritten by "' +
-                option_string + " " + values + '"')
-        setattr(namespace, self.dest, values)
-
-
-def prepare_parse(pkgname, multi_dash_e=None):
+def prepare_parse(pkgname):
     """setup ArgumentParser
 
     multi_dash_e:
@@ -101,13 +90,7 @@
     parser.add_argument("-c", action="store", default="tox.ini",
         dest="configfile",
         help="use the specified config file name.")
-    if multi_dash_e is None:
-        dash_e_action = "store"
-    elif multi_dash_e is False:
-        dash_e_action = CheckSingleStoreAction
-    elif multi_dash_e is True:
-        dash_e_action = "append"
-    parser.add_argument("-e", action=dash_e_action, dest="env",
+    parser.add_argument("-e", action="append", dest="env",
         metavar="envlist",
         help="work against specified environments (ALL selects all).")
     parser.add_argument("--notest", action="store_true", dest="notest",
@@ -376,8 +359,6 @@
 def _split_env(env):
     """if handed a list, action="append" was used for -e """
     envlist = []
-    if not isinstance(env, list):
-        env = [env]
     for to_split in env:
         for single_env in to_split.split(","):
             # "remove True or", if not allowing multiple same runs, update tests


https://bitbucket.org/hpk42/tox/commits/abcc1ea8aee7/
Changeset:   abcc1ea8aee7
User:        Anthon van der Neut
Date:        2013-08-08 11:32:15
Summary:     dash_e: fixes #109 and #111

Behaviour of -e has not changed, but can be set by passing True or False
as a parameter multi_dash_e to tox/_config.py: prepare_parse()

This parameter should come from a user specifyable default value
for backwards compatibility. Default should preferable be True after
that is implemented.

_split_env() was factored out of class parseini to enable testing

The issue #111: error on specifying same env twice ("tox -e py27,py27")
fixed. Multiple specifications of the same environment result in
multiple invocation (this could also be selectable in a
configuration file)
Affected #:  1 file

diff -r 96e1ba41e1c080148fe8baf5c03ba27febd2a330 -r abcc1ea8aee7aad33494dba87bee100f0467787d tox/_config.py
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -67,13 +67,6 @@
             setattr(namespace, self.dest, 0)
 
 def prepare_parse(pkgname):
-    """setup ArgumentParser
-
-    multi_dash_e:
-        None -> silently ignore all but last -e pyXY option (old behaviour
-        False -> take last -e pyXY option, but warn on sys.stdout
-        True -> concatenate
-    """
     parser = argparse.ArgumentParser(description=__doc__,)
         #formatter_class=argparse.ArgumentDefaultsHelpFormatter)
     parser.pkgname = pkgname

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