Allow tests to override pyramid_settings
authorChristophe de Vienne <christophe@unlish.com>
Tue, 28 Apr 2015 11:04:03 +0200
changeset 11564 a6547ff97ce0
parent 11563 f9473eb6a8a9
child 11565 6398be12f8e6
Allow tests to override pyramid_settings Closes #5307426
pyramid_cubicweb/__init__.py
pyramid_cubicweb/tests/__init__.py
--- a/pyramid_cubicweb/__init__.py	Wed Apr 29 11:39:35 2015 +0200
+++ b/pyramid_cubicweb/__init__.py	Tue Apr 28 11:04:03 2015 +0200
@@ -12,7 +12,7 @@
     from ConfigParser import SafeConfigParser
 
 
-def make_cubicweb_application(cwconfig):
+def make_cubicweb_application(cwconfig, settings=None):
     """
     Create a pyramid-based CubicWeb instance from a cubicweb configuration.
 
@@ -23,7 +23,7 @@
     """
     settings_filenames = [os.path.join(cwconfig.apphome, 'pyramid.ini')]
 
-    settings = {}
+    settings = dict(settings) if settings else {}
 
     if cwconfig.debugmode:
         settings_filenames.insert(
--- a/pyramid_cubicweb/tests/__init__.py	Wed Apr 29 11:39:35 2015 +0200
+++ b/pyramid_cubicweb/tests/__init__.py	Tue Apr 28 11:04:03 2015 +0200
@@ -6,6 +6,8 @@
 
 
 class PyramidCWTest(CubicWebTestTC):
+    settings = {}
+
     @classmethod
     def init_config(cls, config):
         super(PyramidCWTest, cls).init_config(config)
@@ -17,7 +19,7 @@
     def setUp(self):
         # Skip CubicWebTestTC setUp
         super(CubicWebTestTC, self).setUp()
-        config = make_cubicweb_application(self.config)
+        config = make_cubicweb_application(self.config, self.settings)
         self.includeme(config)
         self.pyr_registry = config.registry
         self.webapp = webtest.TestApp(config.make_wsgi_app())