[Checkins] SVN: zope.fanstatic/trunk/src/zope/fanstatic/test Factored out test layer with fanstatic middleware.

Jan-Jaap Driessen jdriessen at thehealthagency.com
Sun Jan 2 17:56:05 EST 2011


Log message for revision 119270:
  Factored out test layer with fanstatic middleware.

Changed:
  A   zope.fanstatic/trunk/src/zope/fanstatic/testing.py
  U   zope.fanstatic/trunk/src/zope/fanstatic/tests/tests.py

-=-
Added: zope.fanstatic/trunk/src/zope/fanstatic/testing.py
===================================================================
--- zope.fanstatic/trunk/src/zope/fanstatic/testing.py	                        (rev 0)
+++ zope.fanstatic/trunk/src/zope/fanstatic/testing.py	2011-01-02 22:56:04 UTC (rev 119270)
@@ -0,0 +1,9 @@
+from zope.app.wsgi.testlayer import BrowserLayer
+import fanstatic
+
+class ZopeFanstaticBrowserLayer(BrowserLayer):
+    """ A zope testlayer with fanstatic Injector. """
+
+    def setup_middleware(self, app):
+        return fanstatic.Injector(app)
+

Modified: zope.fanstatic/trunk/src/zope/fanstatic/tests/tests.py
===================================================================
--- zope.fanstatic/trunk/src/zope/fanstatic/tests/tests.py	2011-01-02 22:00:36 UTC (rev 119269)
+++ zope.fanstatic/trunk/src/zope/fanstatic/tests/tests.py	2011-01-02 22:56:04 UTC (rev 119270)
@@ -3,18 +3,18 @@
 
 from zope.interface import Interface
 from zope.component import getGlobalSiteManager
-from zope.app.wsgi.testlayer import BrowserLayer
 from zope.publisher.interfaces.browser import IBrowserRequest
 
 import fanstatic
 from zope.fanstatic.zcml import create_factory
 from zope.fanstatic.tests.view import foo
+from zope.fanstatic.testing import ZopeFanstaticBrowserLayer
 import zope.fanstatic.tests
 
-class ZopeFanstaticBrowserLayer(BrowserLayer):
+class TestLayer(ZopeFanstaticBrowserLayer):
 
     def testSetUp(self):
-        super(ZopeFanstaticBrowserLayer, self).testSetUp()
+        super(TestLayer, self).testSetUp()
         # Because it is difficult to dynamically register a
         # entry_point in tests, we do the setup by hand:
         resource_factory = create_factory(foo)
@@ -28,5 +28,5 @@
     readme = doctest.DocFileSuite(
         '../README.txt',
         optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS)
-    readme.layer = ZopeFanstaticBrowserLayer(zope.fanstatic.tests)
+    readme.layer = TestLayer(zope.fanstatic.tests)
     return unittest.TestSuite([readme])



More information about the checkins mailing list