diff options
author | holger krekel <holger@merlinux.eu> | 2013-11-22 07:51:21 +0100 |
---|---|---|
committer | holger krekel <holger@merlinux.eu> | 2013-11-22 07:51:21 +0100 |
commit | 74e599f5d3360203703c0090450254ba84b6489b (patch) | |
tree | 021f9312fff1dcd981e9a9bc7d700f372f62bd45 | |
parent | 8f1b64a35a51a81ee85f65d3a6776297169e135b (diff) | |
download | tox-74e599f5d3360203703c0090450254ba84b6489b.tar.gz |
merged and slightly modified 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
the complete PR.
-rwxr-xr-x | CHANGELOG | 11 | ||||
-rw-r--r-- | tests/test_config.py | 11 | ||||
-rw-r--r-- | tox/_config.py | 14 |
3 files changed, 24 insertions, 12 deletions
@@ -1,6 +1,13 @@ 1.6.2.dev --------- +- 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 + 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=notset to instruct tox to leave the value @@ -21,8 +28,8 @@ - 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. + platform configs when creating virtualenvs with Python3.3. Thanks + Jorgen Schäfer or investigation and solution sketch. - fix issue128: enable full substitution in install_command, thanks for the PR to Ronald Evers diff --git a/tests/test_config.py b/tests/test_config.py index 517ec29..84e4366 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -65,7 +65,7 @@ class TestVenvConfig: def test_force_dep_version(self, initproj): """ Make sure we can override dependencies configured in tox.ini when using the command line option - --force-dep-version. + --force-dep. """ initproj("example123-0.5", filedefs={ 'tox.ini': ''' @@ -80,8 +80,10 @@ class TestVenvConfig: ''' }) config = parseconfig( - ['--force-dep-version=dep1==1.5', '--force-dep-version=dep2==2.1', '--force-dep-version=dep3==3.0']) - assert config.option.force_dep_version == ['dep1==1.5', 'dep2==2.1', 'dep3==3.0'] + ['--force-dep=dep1==1.5', '--force-dep=dep2==2.1', + '--force-dep=dep3==3.0']) + assert config.option.force_dep== [ + 'dep1==1.5', 'dep2==2.1', 'dep3==3.0'] assert [str(x) for x in config.envconfigs['python'].deps] == [ 'dep1==1.5', 'dep2==2.1', 'dep3==3.0', 'dep4==4.0', ] @@ -1194,7 +1196,8 @@ class TestCmdInvocation: r'*deps=*dep1==2.3, dep2*', ]) # override dep1 specific version, and force version for dep2 - result = cmd.run("tox", "--showconfig", "--force-dep-version=dep1", "--force-dep-version=dep2==5.0") + result = cmd.run("tox", "--showconfig", "--force-dep=dep1", + "--force-dep=dep2==5.0") assert result.ret == 0 result.stdout.fnmatch_lines([ r'*deps=*dep1, dep2==5.0*', diff --git a/tox/_config.py b/tox/_config.py index 0348080..c20e251 100644 --- a/tox/_config.py +++ b/tox/_config.py @@ -125,10 +125,11 @@ def prepare_parse(pkgname): help="set PYTHONHASHSEED to SEED before running commands. " "Defaults to a random integer in the range 1 to 4294967295. " "Passing 'noset' suppresses this behavior.") - parser.add_argument("--force-dep-version", action="append", - metavar="DEP==VER", default=None, + parser.add_argument("--force-dep", action="append", + metavar="REQ", default=None, help="Forces a certain version of one of the dependencies " - "when configuring the virtual environment.") + "when configuring the virtual environment. REQ Examples " + "'pytest<2.4' or 'django>=1.6'.") parser.add_argument("args", nargs="*", help="additional arguments available to command positional substitution") return parser @@ -400,9 +401,9 @@ class parseini: :param config: Config instance :return: the new dependency that should be used for virtual environments """ - if not config.option.force_dep_version: + if not config.option.force_dep: return name - for forced_dep in config.option.force_dep_version: + for forced_dep in config.option.force_dep: if self._is_same_dep(forced_dep, name): return forced_dep return name @@ -410,7 +411,8 @@ class parseini: @classmethod def _is_same_dep(cls, dep1, dep2): """ - Returns True if both dependency definitions refer to the same package, even if versions differ. + Returns True if both dependency definitions refer to the + same package, even if versions differ. """ dep1_name = pkg_resources.Requirement.parse(dep1).project_name dep2_name = pkg_resources.Requirement.parse(dep2).project_name |