[devtools] Disable anonymous login right before executing tests
authorRémi Cardona <remi.cardona@logilab.fr>
Fri, 27 Nov 2015 12:26:17 +0100
changeset 10937 eb05348b0e2d
parent 10936 c3606b52092c
child 10938 a24a13742f3c
[devtools] Disable anonymous login right before executing tests CubicWebTC.init_config is called many times, especially when creating the default database. This database is then reused by all tests in the same directory. The issue is that, if a test has 'anonymous_allowed' set to False, the anonymous user won't be created by postcreate.py in the default database. All other tests will fail miserably if they expected anonymous login to work. By actually disabling anonymous login after _init_repo, the default database (and configuration) will be initialized with a working anonymous user. Closes #7485127.
devtools/testlib.py
--- a/devtools/testlib.py	Mon Nov 30 15:53:35 2015 +0100
+++ b/devtools/testlib.py	Fri Nov 27 12:26:17 2015 +0100
@@ -372,7 +372,6 @@
             config.global_set_option('embed-allowed', re.compile('.*'))
         except Exception: # not in server only configuration
             pass
-        config.set_anonymous_allowed(cls.anonymous_allowed)
 
     @property
     def vreg(self):
@@ -410,6 +409,7 @@
                 self.__class__._repo_init_failed = ex
                 raise
             self.addCleanup(self._close_access)
+        self.config.set_anonymous_allowed(self.anonymous_allowed)
         self.setup_database()
         MAILBOX[:] = [] # reset mailbox