[devtools/testlib] Remove assertions about direct usage of CubicWebTC/AutomaticWebTest

The point is to be able to use nose to run CubicWeb test suite. The issue is that nose's test loader inspects members of all base classes of test case classes to determine test methods and it hits this config property (actually executing it), which breaks the assertion. So just return None instead of failing.

Related to #2502531.

authorDenis Laxalde <denis.laxalde@logilab.fr>
changesetdd460fd7cc3e
branchdefault
phasedraft
hiddenyes
parent revision#480187dd66b3 [web] move AbstractAuthManager near its immediate concrete subclass
child revision#1dc043b7b933 Remove hard dependency on pytest & allow nosetests to run, #50a65a331158 [test] Add __init__.py to test directories
files modified by this revision
devtools/testlib.py
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1427289656 -3600
# Wed Mar 25 14:20:56 2015 +0100
# Node ID dd460fd7cc3e261dccb800df08ef4b97d78090ce
# Parent 480187dd66b3c5b0eebe922e9cba8d4f3a34efaa
[devtools/testlib] Remove assertions about direct usage of CubicWebTC/AutomaticWebTest

The point is to be able to use nose to run CubicWeb test suite. The issue
is that nose's test loader inspects members of all base classes of test case
classes to determine test methods and it hits this `config` property (actually
executing it), which breaks the assertion. So just return None instead of
failing.

Related to #2502531.

diff --git a/devtools/testlib.py b/devtools/testlib.py
@@ -322,12 +322,15 @@
1      def config(cls):
2          """return the configuration object
3 
4          Configuration is cached on the test class.
5          """
6 +        if cls is CubicWebTC:
7 +            # Prevent direct use of CubicWebTC directly to avoid database
8 +            # caching issues
9 +            return None
10          try:
11 -            assert not cls is CubicWebTC, "Don't use CubicWebTC directly to prevent database caching issue"
12              return cls.__dict__['_config']
13          except KeyError:
14              home = abspath(join(dirname(sys.modules[cls.__module__].__file__), cls.appid))
15              config = cls._config = cls.configcls(cls.appid, apphome=home)
16              config.mode = 'test'
@@ -1239,11 +1242,14 @@
17      """import this if you wan automatic tests to be ran"""
18 
19      tags = AutoPopulateTest.tags | Tags('web', 'generated')
20 
21      def setUp(self):
22 -        assert not self.__class__ is AutomaticWebTest, 'Please subclass AutomaticWebTest to prevent database caching issue'
23 +        if self.__class__ is AutomaticWebTest:
24 +            # Prevent direct use of AutomaticWebTest to avoid database caching
25 +            # issues.
26 +            return
27          super(AutomaticWebTest, self).setUp()
28 
29          # access to self.app for proper initialization of the authentication
30          # machinery (else some views may fail)
31          self.app