diff options
| author | Anthon van der Neut <anthon@mnt.org> | 2013-08-08 11:29:48 +0200 |
|---|---|---|
| committer | Anthon van der Neut <anthon@mnt.org> | 2013-08-08 11:29:48 +0200 |
| commit | f870acc2f5b38671b97485f1d8ec838427bac747 (patch) | |
| tree | c92fe8b1d15fac853a5a83614c2894ca5b78e334 | |
| parent | a30e658c78c5675a490b844c1acdc1c81d855a5b (diff) | |
| download | tox-f870acc2f5b38671b97485f1d8ec838427bac747.tar.gz | |
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)
| -rw-r--r-- | tests/test_config.py | 26 | ||||
| -rw-r--r-- | tox/_config.py | 23 |
2 files changed, 11 insertions, 38 deletions
diff --git a/tests/test_config.py b/tests/test_config.py index 6870af1..029bf11 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -931,34 +931,26 @@ class TestCmdInvocation: 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 --git a/tox/_config.py b/tox/_config.py index 16cd288..6b4862f 100644 --- a/tox/_config.py +++ b/tox/_config.py @@ -66,18 +66,7 @@ class CountAction(argparse.Action): 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 @@ def prepare_parse(pkgname, multi_dash_e=None): 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 @@ class parseini: 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 |
