[devtools] Use super() in TestServerConfiguration.__init__()
authorRémi Cardona <remi.cardona@logilab.fr>
Mon, 21 Dec 2015 12:47:35 +0100
changeset 11017 3dfed980071c
parent 11016 d04703f54510
child 11018 1df243392d45
[devtools] Use super() in TestServerConfiguration.__init__() While cleaning up the use of init_config() in WSGIAppTC, I wondered why the method was trying to set the 'https_uiprops' and 'https_datadir_url' attributes on the config, when WebConfiguration's __init__ should be taking care of setting them. WSGIAppTC uses the default configuration - one that derives from ApptestConfiguration (noted as G below). The issue is that the class hierarchy of ApptestConfiguration includes TestServerConfiguration (C in the graph below) which calls ServerConfiguration's __init__ directly (B below). As B does not have an __init__ method, CubicWebConfiguration's __init__ is called directly (A below). This has the unintended consequence of preventing WebConfiguration's __init__ from being called. A / \ B D | | C E \ / F | G | ... A: cwconfig.CubicWebConfiguration B: server.serverconfig.ServerConfiguration C: devtools.TestServerConfiguration D: web.webconfig.WebConfiguration E: etwist.twconfig.WebConfigurationBase F: devtools.BaseApptestConfiguration G: devtools.ApptestConfiguration NB: unittest_wsgi wasn't really broken, as it's the only test in wsgi/test/, but I figured I might as well clean it up. Related to #9297611.
devtools/__init__.py
wsgi/test/unittest_wsgi.py
--- a/devtools/__init__.py	Mon Dec 21 10:08:13 2015 +0100
+++ b/devtools/__init__.py	Mon Dec 21 12:47:35 2015 +0100
@@ -151,7 +151,7 @@
             else: # cube test
                 apphome = abspath('..')
         self._apphome = apphome
-        ServerConfiguration.__init__(self, appid)
+        super(TestServerConfiguration, self).__init__(appid)
         self.init_log(log_threshold, force=True)
         # need this, usually triggered by cubicweb-ctl
         self.load_cwctl_plugins()
--- a/wsgi/test/unittest_wsgi.py	Mon Dec 21 10:08:13 2015 +0100
+++ b/wsgi/test/unittest_wsgi.py	Mon Dec 21 12:47:35 2015 +0100
@@ -110,12 +110,6 @@
         req = CubicWebWsgiRequest(r.environ, self.vreg)
         self.assertEqual(u"é", req.form['arg'])
 
-    @classmethod
-    def init_config(cls, config):
-        super(WSGIAppTC, cls).init_config(config)
-        config.https_uiprops = None
-        config.https_datadir_url = None
-
 
 if __name__ == '__main__':
     import unittest