diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-01-15 00:20:04 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-01-15 00:20:04 +0000 |
| commit | c8cf2256655ee4b34ec501325b9016608b5cce5f (patch) | |
| tree | 065c104d852d70389ce328813e2e8ea33e9885ce /repoze/bfg/tests/test_chameleon_zpt.py | |
| parent | ec54985a5c27846a7e9444c22bcf46ae7e868b66 (diff) | |
| download | pyramid-c8cf2256655ee4b34ec501325b9016608b5cce5f.tar.gz pyramid-c8cf2256655ee4b34ec501325b9016608b5cce5f.tar.bz2 pyramid-c8cf2256655ee4b34ec501325b9016608b5cce5f.zip | |
- Instead of invariably using ``webob.Request`` as the "request
factory" (e.g. in the ``Router`` class) and ``webob.Response`` and
the "response factory" (e.g. in ``render_template_to_response``),
allow both to be overridden via a ZCML utility hook. See the "Using
ZCML Hooks" chapter of the documentation for more information.
Diffstat (limited to 'repoze/bfg/tests/test_chameleon_zpt.py')
| -rw-r--r-- | repoze/bfg/tests/test_chameleon_zpt.py | 59 |
1 files changed, 21 insertions, 38 deletions
diff --git a/repoze/bfg/tests/test_chameleon_zpt.py b/repoze/bfg/tests/test_chameleon_zpt.py index 995dd92e1..088930069 100644 --- a/repoze/bfg/tests/test_chameleon_zpt.py +++ b/repoze/bfg/tests/test_chameleon_zpt.py @@ -1,13 +1,13 @@ import unittest -from zope.component.testing import PlacelessSetup +from zope.testing.cleanup import cleanUp -class Base(PlacelessSetup): +class Base(object): def setUp(self): - PlacelessSetup.setUp(self) + cleanUp() def tearDown(self): - PlacelessSetup.tearDown(self) + cleanUp() def _zcmlConfigure(self): import repoze.bfg.includes @@ -20,13 +20,7 @@ class Base(PlacelessSetup): here = os.path.abspath(os.path.dirname(__file__)) return os.path.join(here, 'fixtures', name) -class ZPTTemplateRendererTests(unittest.TestCase, Base): - def setUp(self): - Base.setUp(self) - - def tearDown(self): - Base.tearDown(self) - +class ZPTTemplateRendererTests(Base, unittest.TestCase): def _getTargetClass(self): from repoze.bfg.chameleon_zpt import ZPTTemplateRenderer return ZPTTemplateRenderer @@ -65,13 +59,7 @@ class ZPTTemplateRendererTests(unittest.TestCase, Base): '<div xmlns="http://www.w3.org/1999/xhtml">\n</div>') -class RenderTemplateTests(unittest.TestCase, Base): - def setUp(self): - Base.setUp(self) - - def tearDown(self): - Base.tearDown(self) - +class RenderTemplateTests(Base, unittest.TestCase): def _getFUT(self): from repoze.bfg.chameleon_zpt import render_template return render_template @@ -85,13 +73,7 @@ class RenderTemplateTests(unittest.TestCase, Base): self.assertEqual(result, '<div xmlns="http://www.w3.org/1999/xhtml">\n</div>') -class RenderTemplateToResponseTests(unittest.TestCase, Base): - def setUp(self): - Base.setUp(self) - - def tearDown(self): - Base.tearDown(self) - +class RenderTemplateToResponseTests(Base, unittest.TestCase): def _getFUT(self): from repoze.bfg.chameleon_zpt import render_template_to_response return render_template_to_response @@ -108,13 +90,20 @@ class RenderTemplateToResponseTests(unittest.TestCase, Base): self.assertEqual(result.status, '200 OK') self.assertEqual(len(result.headerlist), 2) -class GetRendererTests(unittest.TestCase, Base): - def setUp(self): - Base.setUp(self) - - def tearDown(self): - Base.tearDown(self) + def test_iresponsefactory_override(self): + from zope.component import getGlobalSiteManager + gsm = getGlobalSiteManager() + from webob import Response + class Response2(Response): + pass + from repoze.bfg.interfaces import IResponseFactory + gsm.registerUtility(Response2, IResponseFactory) + minimal = self._getTemplatePath('minimal.pt') + render = self._getFUT() + result = render(minimal) + self.failUnless(isinstance(result, Response2)) +class GetRendererTests(Base, unittest.TestCase): def _getFUT(self): from repoze.bfg.chameleon_zpt import get_renderer return get_renderer @@ -162,13 +151,7 @@ class GetRendererTests(unittest.TestCase, Base): result = get('foo') self.failUnless(result is utility) -class GetTemplateTests(unittest.TestCase, Base): - def setUp(self): - Base.setUp(self) - - def tearDown(self): - Base.tearDown(self) - +class GetTemplateTests(Base, unittest.TestCase): def _getFUT(self): from repoze.bfg.chameleon_zpt import get_template return get_template |
