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_text.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_text.py')
| -rw-r--r-- | repoze/bfg/tests/test_chameleon_text.py | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/repoze/bfg/tests/test_chameleon_text.py b/repoze/bfg/tests/test_chameleon_text.py index f61cfe963..992957d0e 100644 --- a/repoze/bfg/tests/test_chameleon_text.py +++ b/repoze/bfg/tests/test_chameleon_text.py @@ -20,13 +20,7 @@ class Base: here = os.path.abspath(os.path.dirname(__file__)) return os.path.join(here, 'fixtures', name) -class TextTemplateRendererTests(unittest.TestCase, Base): - def setUp(self): - Base.setUp(self) - - def tearDown(self): - Base.tearDown(self) - +class TextTemplateRendererTests(Base, unittest.TestCase): def _getTargetClass(self): from repoze.bfg.chameleon_text import TextTemplateRenderer return TextTemplateRenderer @@ -70,13 +64,7 @@ class TextTemplateRendererTests(unittest.TestCase, Base): self.failUnless(isinstance(result, str)) self.assertEqual(result, 'Hello.\n') -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_text import render_template return render_template @@ -89,13 +77,7 @@ class RenderTemplateTests(unittest.TestCase, Base): self.failUnless(isinstance(result, str)) self.assertEqual(result, 'Hello.\n') -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_text import render_template_to_response return render_template_to_response @@ -111,13 +93,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.txt') + render = self._getFUT() + result = render(minimal) + self.failUnless(isinstance(result, Response2)) +class GetRendererTests(Base, unittest.TestCase): def _getFUT(self): from repoze.bfg.chameleon_text import get_renderer return get_renderer |
