Permalink
Browse files

add a test for settings defaults

also add  sublime temp files to gitignore
  • Loading branch information...
1 parent e05c4b4 commit fe3532135bd66a05f1a9e7d4514e121b5cd884b5 Michael R committed Nov 18, 2012
Showing with 21 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +20 −1 pyramid_jinja2/tests/test_settings.py
View
@@ -12,3 +12,4 @@ dist/
.tox
nosetests.xml
pyramid_jinja2/coverage.xml
+*.sublime-*
@@ -40,6 +40,24 @@ def _callFUT(self, info):
from pyramid_jinja2 import renderer_factory
return renderer_factory(info)
+ def test_settings_defaults(self):
+ from pyramid_jinja2 import IJinja2Environment
+ from pyramid_jinja2 import _JINJA2_ENVIRONMENT_DEFAULTS
+
+ # do not setup the registry with any settings so we get the defaults
+ registry = DummyRegistry()
+ # provide minimum amount of information to the renderer
+ info = DummyRendererInfo(registry)
+ # call renderer so the Jinja2 environment is created
+ self._callFUT(info)
+ # get Jinja2 environment
+ environ = registry.queryUtility(IJinja2Environment)
+ # iterate over the defaults and test them
+ # (fyi, this will not work for cache_size)
+ for key_name in _JINJA2_ENVIRONMENT_DEFAULTS:
+ self.assertEqual(getattr(environ, key_name),
+ _JINJA2_ENVIRONMENT_DEFAULTS[key_name])
+
def test_most_settings(self):
from pyramid_jinja2 import IJinja2Environment
@@ -58,9 +76,9 @@ def test_most_settings(self):
'jinja2.autoescape': False,
'jinja2.cache_size': 300
})
+
# provide minimum amount of information to the renderer
info = DummyRendererInfo(registry)
-
# call renderer so the Jinja2 environment is created
self._callFUT(info)
# get Jinja2 environment
@@ -79,4 +97,5 @@ def test_most_settings(self):
self.assertEqual(environ.newline_sequence, '\r')
self.assertEqual(environ.optimized, False)
self.assertEqual(environ.autoescape, False)
+ # this is where cache_size gets set in Jinja2
self.assertEqual(environ.cache.capacity, 300)

0 comments on commit fe35321

Please sign in to comment.