From e4610566d881f707c01d266a7e336084029c83e4 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 20 Sep 2009 22:13:11 +0000 Subject: - The way ``bfg_view`` declarations are scanned for has been modified. This should have no external effects. - An object implementing the ``IRenderer`` interface (and ``ITemplateRenderer`, which is a subclass of ``IRenderer``) must now accept an extra ``system`` argument in its ``__call__`` method implementation. Values computed by the system (as opposed to by the view) are passed by the system in the ``system`` parameter, which will always be a dictionary. Keys in the dictionary include: ``view`` (the view object that returned the value), ``renderer_name`` (the template name or simple name of the renderer), ``context`` (the context object passed to the view), and ``request`` (the request object passed to the view). Previously only ITemplateRenderers received system arguments as elements inside the main ``value`` dictionary. --- repoze/bfg/tests/test_chameleon_zpt.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'repoze/bfg/tests/test_chameleon_zpt.py') diff --git a/repoze/bfg/tests/test_chameleon_zpt.py b/repoze/bfg/tests/test_chameleon_zpt.py index f6d7c0da5..381a1d0bf 100644 --- a/repoze/bfg/tests/test_chameleon_zpt.py +++ b/repoze/bfg/tests/test_chameleon_zpt.py @@ -9,12 +9,6 @@ class Base(object): def tearDown(self): cleanUp() - def _zcmlConfigure(self): - import repoze.bfg.includes - import zope.configuration.xmlconfig - zope.configuration.xmlconfig.file('configure.zcml', - package=repoze.bfg.includes) - def _getTemplatePath(self, name): import os here = os.path.abspath(os.path.dirname(__file__)) @@ -41,16 +35,19 @@ class ZPTTemplateRendererTests(Base, unittest.TestCase): verifyClass(ITemplateRenderer, self._getTargetClass()) def test_call(self): - self._zcmlConfigure() minimal = self._getTemplatePath('minimal.pt') instance = self._makeOne(minimal) - result = instance({}) + result = instance({}, {}) self.failUnless(isinstance(result, unicode)) self.assertEqual(result, '
\n
') + def test_call_with_nondict_value(self): + minimal = self._getTemplatePath('minimal.pt') + instance = self._makeOne(minimal) + self.assertRaises(ValueError, instance, None, {}) + def test_implementation(self): - self._zcmlConfigure() minimal = self._getTemplatePath('minimal.pt') instance = self._makeOne(minimal) result = instance.implementation()() @@ -65,7 +62,6 @@ class RenderTemplateTests(Base, unittest.TestCase): return render_template(name, **kw) def test_it(self): - self._zcmlConfigure() minimal = self._getTemplatePath('minimal.pt') result = self._callFUT(minimal) self.failUnless(isinstance(result, unicode)) @@ -78,7 +74,6 @@ class RenderTemplateToResponseTests(Base, unittest.TestCase): return render_template_to_response(name, **kw) def test_it(self): - self._zcmlConfigure() minimal = self._getTemplatePath('minimal.pt') result = self._callFUT(minimal) from webob import Response @@ -149,7 +144,6 @@ class GetTemplateTests(Base, unittest.TestCase): return get_template(name) def test_nonabs_registered(self): - self._zcmlConfigure() from zope.component import getGlobalSiteManager from zope.component import queryUtility from repoze.bfg.chameleon_zpt import ZPTTemplateRenderer @@ -163,7 +157,6 @@ class GetTemplateTests(Base, unittest.TestCase): self.assertEqual(queryUtility(ITemplateRenderer, minimal), utility) def test_nonabs_unregistered(self): - self._zcmlConfigure() from zope.component import getGlobalSiteManager from zope.component import queryUtility from repoze.bfg.chameleon_zpt import ZPTTemplateRenderer -- cgit v1.2.3