[tox] Use py.test to run tests
authorDenis Laxalde <denis.laxalde@logilab.fr>
Thu, 14 Jan 2016 17:14:16 +0100
changeset 11250 597f02c5cf5a
parent 11249 0ff4c02a1871
child 11251 b66a8c3eebeb
[tox] Use py.test to run tests In unittest_rqlrewrite.py and repotest.py, rename utility functions so that they are not considered as "test functions" by py.test.
cubicweb/devtools/repotest.py
cubicweb/server/test/unittest_ssplanner.py
cubicweb/test/unittest_rqlrewrite.py
tox.ini
--- a/cubicweb/devtools/repotest.py	Thu May 19 14:21:21 2016 +0200
+++ b/cubicweb/devtools/repotest.py	Thu Jan 14 17:14:16 2016 +0100
@@ -37,7 +37,7 @@
     # a[0] may be a dict or a key/value tuple
     return (sorted(dict(a[0]).items()), [e.expression for e in a[1]])
 
-def test_plan(self, rql, expected, kwargs=None):
+def check_plan(self, rql, expected, kwargs=None):
     with self.session.new_cnx() as cnx:
         plan = self._prepare_plan(cnx, rql, kwargs)
         self.planner.build_plan(plan)
--- a/cubicweb/server/test/unittest_ssplanner.py	Thu May 19 14:21:21 2016 +0200
+++ b/cubicweb/server/test/unittest_ssplanner.py	Thu Jan 14 17:14:16 2016 +0100
@@ -17,7 +17,7 @@
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
 
 from cubicweb.devtools import TestServerConfiguration, get_test_db_handler
-from cubicweb.devtools.repotest import BasePlannerTC, test_plan
+from cubicweb.devtools.repotest import BasePlannerTC, check_plan
 from cubicweb.server.ssplanner import SSPlanner
 
 # keep cnx so it's not garbage collected and the associated session closed
@@ -34,7 +34,7 @@
     del repo, cnx
 
 class SSPlannerTC(BasePlannerTC):
-    _test = test_plan
+    _test = check_plan
 
     def setUp(self):
         self.__class__.repo = repo
--- a/cubicweb/test/unittest_rqlrewrite.py	Thu May 19 14:21:21 2016 +0200
+++ b/cubicweb/test/unittest_rqlrewrite.py	Thu Jan 14 17:14:16 2016 +0100
@@ -77,10 +77,10 @@
         snippets.append((dict([v]), rqlexprs))
     rqlhelper.compute_solutions(rqlst.children[0], {'eid': eid_func_map}, kwargs=kwargs)
     rewriter.rewrite(rqlst.children[0], snippets, kwargs, existingvars)
-    test_vrefs(rqlst.children[0])
+    check_vrefs(rqlst.children[0])
     return rewriter.rewritten
 
-def test_vrefs(node):
+def check_vrefs(node):
     vrefmaps = {}
     selects = []
     for vref in node.iget_nodes(nodes.VariableRef):
@@ -808,7 +808,7 @@
                                 kwargs=kwargs)
     rewriter.rewrite(rqlst)
     for select in rqlst.children:
-        test_vrefs(select)
+        check_vrefs(select)
     return rewriter.rewritten
 
 
--- a/tox.ini	Thu May 19 14:21:21 2016 +0200
+++ b/tox.ini	Thu Jan 14 17:14:16 2016 +0100
@@ -22,23 +22,24 @@
   sobjects: -r{toxinidir}/cubicweb/sobjects/test/requirements.txt
   web: -r{toxinidir}/cubicweb/web/test/requirements.txt
   wsgi: -r{toxinidir}/cubicweb/wsgi/test/requirements.txt
+  pytest
 commands =
   py34-cubicweb: touch {envdir}/share/cubicweb/cubes/__init__.py
   py34-server: touch {envdir}/share/cubicweb/cubes/__init__.py
   py34-sobjects: touch {envdir}/share/cubicweb/cubes/__init__.py
   py34-web: touch {envdir}/share/cubicweb/cubes/__init__.py
   cubicweb: {envpython} -m pip install --upgrade --no-deps --quiet git+git://github.com/logilab/yapps@master#egg=yapps
-  cubicweb: {envpython} -c 'from logilab.common import pytest; pytest.run()' -t {toxinidir}/cubicweb/test {posargs}
-  dataimport: {envpython} -c 'from logilab.common import pytest; pytest.run()' -t {toxinidir}/cubicweb/dataimport/test {posargs}
-  devtools: {envpython} -c 'from logilab.common import pytest; pytest.run()' -t {toxinidir}/cubicweb/devtools/test {posargs}
-  entities: {envpython} -c 'from logilab.common import pytest; pytest.run()' -t {toxinidir}/cubicweb/entities/test {posargs}
-  etwist: {envpython} -c 'from logilab.common import pytest; pytest.run()' -t {toxinidir}/cubicweb/etwist/test {posargs}
-  ext: {envpython} -c 'from logilab.common import pytest; pytest.run()' -t {toxinidir}/cubicweb/ext/test {posargs}
-  hooks: {envpython} -c 'from logilab.common import pytest; pytest.run()' -t {toxinidir}/cubicweb/hooks/test {posargs}
-  server: {envpython} -c 'from logilab.common import pytest; pytest.run()' -t {toxinidir}/cubicweb/server/test {posargs}
-  sobjects: {envpython} -c 'from logilab.common import pytest; pytest.run()' -t {toxinidir}/cubicweb/sobjects/test {posargs}
-  web: {envpython} -c 'from logilab.common import pytest; pytest.run()' -t {toxinidir}/cubicweb/web/test {posargs}
-  wsgi: {envpython} -c 'from logilab.common import pytest; pytest.run()' -t {toxinidir}/cubicweb/wsgi/test {posargs}
+  cubicweb: {envpython} -m pytest {toxinidir}/cubicweb/test {posargs}
+  dataimport: {envpython} -m pytest {toxinidir}/cubicweb/dataimport/test {posargs}
+  devtools: {envpython} -m pytest {toxinidir}/cubicweb/devtools/test {posargs}
+  entities: {envpython} -m pytest {toxinidir}/cubicweb/entities/test {posargs}
+  etwist: {envpython} -m pytest {toxinidir}/cubicweb/etwist/test {posargs}
+  ext: {envpython} -m pytest {toxinidir}/cubicweb/ext/test {posargs}
+  hooks: {envpython} -m pytest {toxinidir}/cubicweb/hooks/test {posargs}
+  server: {envpython} -m pytest {toxinidir}/cubicweb/server/test {posargs}
+  sobjects: {envpython} -m pytest {toxinidir}/cubicweb/sobjects/test {posargs}
+  web: {envpython} -m pytest {toxinidir}/cubicweb/web/test {posargs}
+  wsgi: {envpython} -m pytest {toxinidir}/cubicweb/wsgi/test {posargs}
 
 [testenv:doc]
 changedir = doc
@@ -47,3 +48,6 @@
 deps =
   sphinx
 commands = sphinx-build -b html -d {envtmpdir}/doctrees .  {envtmpdir}/html
+
+[pytest]
+python_files = *test_*.py