[Pytest-commit] commit/tox: 4 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Sep 2 14:48:34 CEST 2014
4 new commits in tox:
https://bitbucket.org/hpk42/tox/commits/35145c72c733/
Changeset: 35145c72c733
User: suor
Date: 2014-08-09 14:55:53
Summary: Remove factor negation support
Affected #: 2 files
diff -r d835cca51418210730ba8c9cc88a8829bc7cb05d -r 35145c72c7334ddb0a7fd7f5d5e5e77353e09827 tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -835,20 +835,20 @@
def test_factors(self, newconfig):
inisource="""
[tox]
- envlist = a,b
+ envlist = a-x,b
[testenv]
deps=
dep-all
a: dep-a
b: dep-b
- !a: dep-not-a
+ x: dep-x
"""
conf = newconfig([], inisource)
configs = conf.envconfigs
- assert [dep.name for dep in configs['a'].deps] == ["dep-all", "dep-a"]
- assert [dep.name for dep in configs['b'].deps] == \
- ["dep-all", "dep-b", "dep-not-a"]
+ assert [dep.name for dep in configs['a-x'].deps] == \
+ ["dep-all", "dep-a", "dep-x"]
+ assert [dep.name for dep in configs['b'].deps] == ["dep-all", "dep-b"]
def test_default_factors(self, newconfig):
inisource="""
diff -r d835cca51418210730ba8c9cc88a8829bc7cb05d -r 35145c72c7334ddb0a7fd7f5d5e5e77353e09827 tox/_config.py
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -302,7 +302,7 @@
factors = set()
if section in self._cfg:
for _, value in self._cfg[section].items():
- factors.update(re.findall(r'^!?(\w+)\:\s+', value, re.M))
+ factors.update(re.findall(r'^(\w+)\:\s+', value, re.M))
return factors
def _makeenvconfig(self, name, section, subs, config):
@@ -628,12 +628,12 @@
def _apply_factors(self, s):
def factor_line(line):
- m = re.search(r'^(!)?(\w+)\:\s+(.+)', line)
+ m = re.search(r'^(\w+)\:\s+(.+)', line)
if not m:
return line
- negate, factor, line = m.groups()
- if bool(negate) ^ (factor in self.factors):
+ factor, line = m.groups()
+ if factor in self.factors:
return line
lines = s.strip().splitlines()
https://bitbucket.org/hpk42/tox/commits/34a35ffe5e17/
Changeset: 34a35ffe5e17
User: suor
Date: 2014-08-09 16:19:09
Summary: Support boolean ops on factors
Affected #: 2 files
diff -r 35145c72c7334ddb0a7fd7f5d5e5e77353e09827 -r 34a35ffe5e17a0a162cc6b635c607573d7e39641 tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -850,6 +850,24 @@
["dep-all", "dep-a", "dep-x"]
assert [dep.name for dep in configs['b'].deps] == ["dep-all", "dep-b"]
+ def test_factor_ops(self, newconfig):
+ inisource="""
+ [tox]
+ envlist = {a,b}-{x,y}
+
+ [testenv]
+ deps=
+ a,b: dep-a-or-b
+ a-x: dep-a-and-x
+ {a,b}-y: dep-ab-and-y
+ """
+ configs = newconfig([], inisource).envconfigs
+ get_deps = lambda env: [dep.name for dep in configs[env].deps]
+ assert get_deps("a-x") == ["dep-a-or-b", "dep-a-and-x"]
+ assert get_deps("a-y") == ["dep-a-or-b", "dep-ab-and-y"]
+ assert get_deps("b-x") == ["dep-a-or-b"]
+ assert get_deps("b-y") == ["dep-a-or-b", "dep-ab-and-y"]
+
def test_default_factors(self, newconfig):
inisource="""
[tox]
diff -r 35145c72c7334ddb0a7fd7f5d5e5e77353e09827 -r 34a35ffe5e17a0a162cc6b635c607573d7e39641 tox/_config.py
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -302,7 +302,8 @@
factors = set()
if section in self._cfg:
for _, value in self._cfg[section].items():
- factors.update(re.findall(r'^(\w+)\:\s+', value, re.M))
+ exprs = re.findall(r'^([\w{},-]+)\:\s+', value, re.M)
+ factors.update(*mapcat(_split_factor_expr, exprs))
return factors
def _makeenvconfig(self, name, section, subs, config):
@@ -434,12 +435,17 @@
dep2_name = pkg_resources.Requirement.parse(dep2).project_name
return dep1_name == dep2_name
+
def _split_env(env):
"""if handed a list, action="append" was used for -e """
if not isinstance(env, list):
env = [env]
return mapcat(_expand_envstr, env)
+def _split_factor_expr(expr):
+ partial_envs = _expand_envstr(expr)
+ return [set(e.split('-')) for e in partial_envs]
+
def _expand_envstr(envstr):
# split by commas not in groups
tokens = re.split(r'(\{[^}]+\})|,', envstr)
@@ -628,12 +634,12 @@
def _apply_factors(self, s):
def factor_line(line):
- m = re.search(r'^(\w+)\:\s+(.+)', line)
+ m = re.search(r'^([\w{},-]+)\:\s+(.+)', line)
if not m:
return line
- factor, line = m.groups()
- if factor in self.factors:
+ expr, line = m.groups()
+ if any(fs <= self.factors for fs in _split_factor_expr(expr)):
return line
lines = s.strip().splitlines()
https://bitbucket.org/hpk42/tox/commits/d415689eb8ef/
Changeset: d415689eb8ef
User: suor
Date: 2014-08-09 16:44:41
Summary: Docs for factor expressions
Affected #: 1 file
diff -r 34a35ffe5e17a0a162cc6b635c607573d7e39641 -r d415689eb8ef671f6940a3e8c8c3d4677b153451 doc/config.txt
--- a/doc/config.txt
+++ b/doc/config.txt
@@ -405,7 +405,7 @@
pytest
django15: Django>=1.5,<1.6
django16: Django>=1.6,<1.7
- !py27: unittest2
+ py26: unittest2
commands = py.test
This uses two new facilities of tox-1.8:
@@ -417,6 +417,7 @@
Let's go through this step by step.
+
Generative envlist
+++++++++++++++++++++++
@@ -432,7 +433,7 @@
py27-django15
py27-django16
-You can still list environments explicitely along with generated ones::
+You can still list environments explicitly along with generated ones::
envlist = {py26,py27}-django{15,16}, docs, flake
@@ -441,13 +442,13 @@
To help with understanding how the variants will produce section values,
you can ask tox to show their expansion with a new option::
- $ tox -l
- py26-django15
- py26-django16
- py27-django15
- py27-django16
- docs
- flake
+ $ tox -l
+ py26-django15
+ py26-django16
+ py27-django15
+ py27-django16
+ docs
+ flake
Factors and factor-conditional settings
@@ -471,23 +472,14 @@
pytest
django15: Django>=1.5,<1.6
django16: Django>=1.6,<1.7
- !py27: unittest2
+ py26: unittest2
-The last line here uses negation of a factor, this means ``unittest2`` will be
-in ``deps`` for all pythons except python2.7. The whole effect of this setting
-definition could be described with a table:
+Reading it line by line:
-=============== ==================================
-environment deps
-=============== ==================================
-py26-django15 pytest, Django>=1.5,<1.6, unitest2
-py26-django16 pytest, Django>=1.6,<1.7, unitest2
-py27-django15 pytest, Django>=1.5,<1.6
-py27-django16 pytest, Django>=1.6,<1.7
-=============== ==================================
-
-And this table can significantly grow as you have more dependencies and other
-factors such as platform, python version and/or database.
+- ``pytest`` will be included unconditionally,
+- ``Django>=1.5,<1.6`` will be included for environments containing ``django15`` factor,
+- ``Django>=1.6,<1.7`` similarly depends on ``django16`` factor,
+- ``unittest`` will be loaded for Python 2.6 environments.
.. note::
@@ -496,6 +488,34 @@
setting.
+Complex factor conditions
++++++++++++++++++++++++++
+
+Sometimes you need to specify same line for several factors or create a special case for
+a combination of factors. Here is how you do it::
+
+ [tox]
+ envlist = py{25,26,27}-django{14,15,16}-{sqlite,mysql}
+
+ [testenv]
+ deps =
+ py25-django14: simplejson ; use it only for this specific combination
+ py25,py26: unittest2 ; use it for both py25 and py26
+ py{25,26}-django14: mock ; patching whatever in older python/django combo
+
+Take a look at first ``deps`` line. It shows how you can special case something
+for a combination of factors, you just join combining factors with a hyphen.
+This particular line states that ``simplejson`` will be loaded for python 2.5, django 1.4
+environments, e.g. ``py25-django14-sqlite`` and ``py25-django14-mysql``.
+
+The second line shows how you use same line for several factors - by listing them
+delimited by commas. It's possible to list not only simple factors, but also their
+combinations like ``py25-django14,py26-django14``.
+
+Finally, factor expressions are expanded the same way as envlist, so a last example
+could be rewritten as ``py{25,26}-django14``.
+
+
Other Rules and notes
=====================
https://bitbucket.org/hpk42/tox/commits/8c6dbbf625b7/
Changeset: 8c6dbbf625b7
User: suor
Date: 2014-08-11 12:17:59
Summary: Update complex factor docs
Affected #: 1 file
diff -r d415689eb8ef671f6940a3e8c8c3d4677b153451 -r 8c6dbbf625b7f41e851ea083faada2695bbdc1c0 doc/config.txt
--- a/doc/config.txt
+++ b/doc/config.txt
@@ -491,29 +491,42 @@
Complex factor conditions
+++++++++++++++++++++++++
-Sometimes you need to specify same line for several factors or create a special case for
-a combination of factors. Here is how you do it::
+Sometimes you need to specify same line for several factors or create a special
+case for a combination of factors. Here is how you do it::
[tox]
- envlist = py{25,26,27}-django{14,15,16}-{sqlite,mysql}
+ envlist = py{26,27,33}-django{15,16}-{sqlite,mysql}
[testenv]
deps =
- py25-django14: simplejson ; use it only for this specific combination
- py25,py26: unittest2 ; use it for both py25 and py26
- py{25,26}-django14: mock ; patching whatever in older python/django combo
+ py33-mysql: PyMySQL ; use if both py33 and mysql are in an env name
+ py26,py27: urllib3 ; use if any of py26 or py27 are in an env name
+ py{26,27}-sqlite: mock ; mocking sqlite in python 2.x
Take a look at first ``deps`` line. It shows how you can special case something
for a combination of factors, you just join combining factors with a hyphen.
-This particular line states that ``simplejson`` will be loaded for python 2.5, django 1.4
-environments, e.g. ``py25-django14-sqlite`` and ``py25-django14-mysql``.
+This particular line states that ``PyMySQL`` will be loaded for python 3.3,
+mysql environments, e.g. ``py33-django15-mysql`` and ``py33-django16-mysql``.
-The second line shows how you use same line for several factors - by listing them
-delimited by commas. It's possible to list not only simple factors, but also their
-combinations like ``py25-django14,py26-django14``.
+The second line shows how you use same line for several factors - by listing
+them delimited by commas. It's possible to list not only simple factors, but
+also their combinations like ``py26-sqlite,py27-sqlite``.
-Finally, factor expressions are expanded the same way as envlist, so a last example
-could be rewritten as ``py{25,26}-django14``.
+Finally, factor expressions are expanded the same way as envlist, so last
+example could be rewritten as ``py{26,27}-sqlite``.
+
+.. note::
+
+ Factors don't do substring matching against env name, instead every
+ hyphenated expression is split by ``-`` and if ALL the factors in an
+ expression are also factors of an env then that condition is considered
+ hold.
+
+ For example, environment ``py26-mysql``:
+
+ - could be matched with expressions ``py26``, ``py26-mysql``,
+ ``mysql-py26``,
+ - but not with ``py2`` or ``py26-sql``.
Other Rules and notes
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