# HG changeset patch # User Denis Laxalde # Date 1455787385 -3600 # Node ID 66c44d3d97af9451c77131ffa40c9ae2458cb867 # Parent 2a7fb3422ae1a0312336384d760b135bc5f7593e [devtools/testlib] Issue a RuntimeError when a generative tests is detected Otherwise, generative tests *à la logilab-common* in CubicWebTC test cases would silently not run (at least using logilab.common.pytest runner). diff -r 2a7fb3422ae1 -r 66c44d3d97af cubicweb/devtools/testlib.py --- a/cubicweb/devtools/testlib.py Thu Feb 18 09:30:58 2016 +0100 +++ b/cubicweb/devtools/testlib.py Thu Feb 18 10:23:05 2016 +0100 @@ -23,6 +23,7 @@ from os.path import dirname, join, abspath from math import log from contextlib import contextmanager +from inspect import isgeneratorfunction from itertools import chain from six import text_type, string_types @@ -317,6 +318,14 @@ self._open_access = set() super(CubicWebTC, self).__init__(*args, **kwargs) + def run(self, *args, **kwds): + testMethod = getattr(self, self._testMethodName) + if isgeneratorfunction(testMethod): + raise RuntimeError( + '%s appears to be a generative test. This is not handled ' + 'anymore, use subTest API instead.' % self) + return super(CubicWebTC, self).run(*args, **kwds) + # repository connection handling ########################################### def new_access(self, login): diff -r 2a7fb3422ae1 -r 66c44d3d97af doc/changes/3.23.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/changes/3.23.rst Thu Feb 18 10:23:05 2016 +0100 @@ -0,0 +1,12 @@ +3.23 (UNRELEASED) +================= + +Backwards-incompatible changes +------------------------------ + +* Generative tests *à la logilab-common* are not supported anymore in + `CubicWebTC`. It is advised to use the subtests_ API (available on + `CubicWebTC` either from the standard library as of Python 3.4 or through + unittest2 package otherwise). + +.. _subtests: https://docs.python.org/3/library/unittest.html#distinguishing-test-iterations-using-subtests