Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Commit

Permalink
Factored out test layer with fanstatic middleware.
Browse files Browse the repository at this point in the history
  • Loading branch information
janjaapdriessen committed Jan 2, 2011
1 parent aff479b commit 773fba2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/zope/fanstatic/testing.py
@@ -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)

8 changes: 4 additions & 4 deletions src/zope/fanstatic/tests/tests.py
Expand Up @@ -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)
Expand All @@ -28,5 +28,5 @@ def test_suite():
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])

0 comments on commit 773fba2

Please sign in to comment.