diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-01-11 02:20:52 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-01-11 02:20:52 +0000 |
| commit | 358dc276d28fb395a9a742ff53dc66ee115c58ad (patch) | |
| tree | c92dd9bdd24f4b473a7e56a7a498aac046dd4ed4 /repoze/bfg/tests/test_template.py | |
| parent | be268487581bf94086ecc18904113d71237612e1 (diff) | |
| download | pyramid-358dc276d28fb395a9a742ff53dc66ee115c58ad.tar.gz pyramid-358dc276d28fb395a9a742ff53dc66ee115c58ad.tar.bz2 pyramid-358dc276d28fb395a9a742ff53dc66ee115c58ad.zip | |
Merge router-simplify branch. Changelog below.
Bug Fixes
---------
- Fix a bug where the Paste configuration's ``unicode_path_segments``
(and os.environ's ``BFG_UNICODE_PATH_SEGMENTS``) may have been
defaulting to false in some circumstances. It now always defaults
to true, matching the documentation and intent.
- The ``repoze.bfg.traversal.find_model`` API did not work properly
when passed a ``path`` argument which was unicode and contained
high-order bytes when the ``unicode_path_segments`` or
``BFG_UNICODE_PATH_SEGMENTS`` configuration variables were "true".
- A new module was added: ``repoze.bfg.settings``. This contains
deployment-settings-related code.
Behavior Changes
----------------
- The ``make_app`` callable within ``repoze.bfg.router`` now registers
the ``root_policy`` argument as a utility (unnamed, using the new
``repoze.bfg.interfaces.IRootFactory`` as a provides interface)
rather than passing it as the first argument to the
``repoze.bfg.router.Router`` class. As a result the
``repoze.bfg.router.Router`` router class only accepts a single
argument: ``registry``. The ``repoze.bfg.router.Router`` class
retrieves the root policy via a utility lookup now. The
``repoze.bfg.router.make_app`` API also now performs some important
application registrations that were previously handled inside
``repoze.bfg.registry.makeRegistry``.
- The ``repoze.bfg.settings.Settings`` class (an instance of which is
registered as a utility providing
``repoze.bfg.interfaces.ISettings`` when any application is started)
now automatically calls ``repoze.bfg.settings.get_options`` on the
options passed to its constructor. This means that usage of
``get_options`` within an application's ``make_app`` function is no
longer required (the "raw" ``options`` dict or None may be passed).
Deprecations
------------
- Moved the ``repoze.bfg.registry.Settings`` class. This has been
moved to ``repoze.bfg.settings.Settings``. A deprecation warning is
issued when it is imported from the older location.
- Moved the ``repoze.bfg.registry.get_options`` function This has been
moved to ``repoze.bfg.settings.get_options``. A deprecation warning
is issued when it is imported from the older location.
- The ``repoze.bfg.interfaces.IRootPolicy`` interface was renamed
within the interfaces package. It has been renamed to
``IRootFactory``. A deprecation warning is issued when it is
imported from the older location.
Diffstat (limited to 'repoze/bfg/tests/test_template.py')
| -rw-r--r-- | repoze/bfg/tests/test_template.py | 80 |
1 files changed, 29 insertions, 51 deletions
diff --git a/repoze/bfg/tests/test_template.py b/repoze/bfg/tests/test_template.py index 31aa074d8..8d16972b8 100644 --- a/repoze/bfg/tests/test_template.py +++ b/repoze/bfg/tests/test_template.py @@ -1,18 +1,18 @@ import unittest -from zope.component.testing import PlacelessSetup +from zope.testing.cleanup import cleanUp -class Base(PlacelessSetup): +class Base(object): def setUp(self): - from zope.deprecation import __show__ - __show__.off() - PlacelessSetup.setUp(self) + cleanUp() + import warnings + warnings.simplefilter('ignore') def tearDown(self): - from zope.deprecation import __show__ - __show__.on() - PlacelessSetup.tearDown(self) - + cleanUp() + import warnings + warnings.resetwarnings() + def _zcmlConfigure(self): import repoze.bfg.includes import zope.configuration.xmlconfig @@ -24,42 +24,28 @@ class Base(PlacelessSetup): here = os.path.abspath(os.path.dirname(__file__)) return os.path.join(here, 'fixtures', name) -class RenderTemplateTests(unittest.TestCase, Base): - def setUp(self): - Base.setUp(self) - - def tearDown(self): - Base.tearDown(self) - - def _getFUT(self): +class RenderTemplateTests(Base, unittest.TestCase): + def _callFUT(self, *arg, **kw): from repoze.bfg.template import render_template - return render_template + return render_template(*arg, **kw) def test_it(self): self._zcmlConfigure() minimal = self._getTemplatePath('minimal.pt') - render = self._getFUT() - result = render(minimal) + result = self._callFUT(minimal) self.failUnless(isinstance(result, str)) 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) - - def _getFUT(self): +class RenderTemplateToResponseTests(Base, unittest.TestCase): + def _callFUT(self, *arg, **kw): from repoze.bfg.template import render_template_to_response - return render_template_to_response + return render_template_to_response(*arg, **kw) def test_it(self): self._zcmlConfigure() minimal = self._getTemplatePath('minimal.pt') - render = self._getFUT() - result = render(minimal) + result = self._callFUT(minimal) from webob import Response self.failUnless(isinstance(result, Response)) self.assertEqual(result.app_iter, @@ -67,45 +53,37 @@ class RenderTemplateToResponseTests(unittest.TestCase, Base): self.assertEqual(result.status, '200 OK') self.assertEqual(len(result.headerlist), 2) -class GetTemplateTests(unittest.TestCase, Base): - def setUp(self): - Base.setUp(self) - - def tearDown(self): - Base.tearDown(self) - - def _getFUT(self): +class GetTemplateTests(Base, unittest.TestCase): + def _callFUT(self, *arg, **kw): from repoze.bfg.template import get_template - return get_template + return get_template(*arg, **kw) def test_nonabs_registered(self): self._zcmlConfigure() from zope.component import getGlobalSiteManager from zope.component import queryUtility from repoze.bfg.chameleon_zpt import ZPTTemplateFactory - from repoze.bfg.interfaces import ITemplate + from repoze.bfg.interfaces import ITemplateRenderer minimal = self._getTemplatePath('minimal.pt') utility = ZPTTemplateFactory(minimal) gsm = getGlobalSiteManager() - gsm.registerUtility(utility, ITemplate, name=minimal) - get = self._getFUT() - result = get(minimal) + gsm.registerUtility(utility, ITemplateRenderer, name=minimal) + result = self._callFUT(minimal) self.assertEqual(result.filename, minimal) - self.assertEqual(queryUtility(ITemplate, minimal), utility) + 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 ZPTTemplateFactory - from repoze.bfg.interfaces import ITemplate + from repoze.bfg.interfaces import ITemplateRenderer minimal = self._getTemplatePath('minimal.pt') - self.assertEqual(queryUtility(ITemplate, minimal), None) + self.assertEqual(queryUtility(ITemplateRenderer, minimal), None) utility = ZPTTemplateFactory(minimal) gsm = getGlobalSiteManager() - gsm.registerUtility(utility, ITemplate, name=minimal) - get = self._getFUT() - result = get(minimal) + gsm.registerUtility(utility, ITemplateRenderer, name=minimal) + result = self._callFUT(minimal) self.assertEqual(result.filename, minimal) - self.assertEqual(queryUtility(ITemplate, minimal), utility) + self.assertEqual(queryUtility(ITemplateRenderer, minimal), utility) |
