本文整理汇总了Python中pyramid_jinja2.includeme函数的典型用法代码示例。如果您正苦于以下问题:Python includeme函数的具体用法?Python includeme怎么用?Python includeme使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了includeme函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_directory
def test_directory(self):
from pyramid_jinja2 import includeme
config = testing.setUp()
config.registry.settings['jinja2.bytecode_caching_directory'] = '/foobar'
includeme(config)
env = config.get_jinja2_environment()
self.assertEqual(env.bytecode_cache.directory, text_('/foobar'))
示例2: test_it
def test_it(self):
from jinja2.environment import Environment
from pyramid_jinja2 import includeme
config = testing.setUp()
includeme(config)
self.assertEqual(config.get_jinja2_environment().__class__,
Environment)
示例3: test_it_relative_to_package
def test_it_relative_to_package(self):
import pyramid_jinja2.tests
from pyramid_jinja2 import includeme
import os
config = testing.setUp()
# hack because pyramid pre 1.6 doesn't configure testing configurator
# with the correct package name
config.package = pyramid_jinja2.tests
config.package_name = 'pyramid_jinja2.tests'
config.add_settings({'jinja2.directories': 'foobar'})
includeme(config)
env = config.get_jinja2_environment()
self.assertEqual(
[x.split(os.sep)[-2:] for x in env.loader.searchpath][0],
['pyramid_jinja2', 'tests'])
self.assertEqual(
[x.split(os.sep)[-3:] for x in env.loader.searchpath][1:],
[['pyramid_jinja2', 'tests', 'foobar']])
config.add_jinja2_search_path('grrr')
self.assertEqual(
[x.split(os.sep)[-2:] for x in env.loader.searchpath][0],
['pyramid_jinja2', 'tests'])
self.assertEqual(
[x.split(os.sep)[-3:] for x in env.loader.searchpath][1:],
[['pyramid_jinja2', 'tests', 'foobar'],
['pyramid_jinja2', 'tests', 'grrr']])
示例4: test_pyramid_reload_templates
def test_pyramid_reload_templates(self):
from pyramid_jinja2 import includeme
config = testing.setUp()
config.registry.settings = {}
config.registry.settings['pyramid.reload_templates'] = 'true'
includeme(config)
env = config.get_jinja2_environment()
self.assertTrue(env.auto_reload)
示例5: test_it
def test_it(self):
from pyramid.interfaces import IRendererFactory
from pyramid_jinja2 import includeme
from pyramid_jinja2 import renderer_factory
config = testing.setUp()
includeme(config)
utility = config.registry.getUtility(IRendererFactory, name='.jinja2')
self.assertEqual(utility, renderer_factory)
示例6: test_default
def test_default(self):
from pyramid_jinja2 import includeme
config = testing.setUp()
config.registry.settings = {}
includeme(config)
env = config.get_jinja2_environment()
self.assertTrue(env.bytecode_cache is None)
self.assertFalse(env.auto_reload)
示例7: test_directory
def test_directory(self):
import tempfile
from pyramid_jinja2 import includeme
tmpdir = tempfile.mkdtemp()
config = testing.setUp()
config.registry.settings['jinja2.bytecode_caching_directory'] = tmpdir
includeme(config)
env = config.get_jinja2_environment()
self.assertEqual(env.bytecode_cache.directory, tmpdir)
示例8: test_default
def test_default(self):
from pyramid_jinja2 import includeme
import jinja2.bccache
config = testing.setUp()
includeme(config)
env = config.get_jinja2_environment()
self.assertTrue(isinstance(env.bytecode_cache,
jinja2.bccache.FileSystemBytecodeCache))
self.assertTrue(env.bytecode_cache.directory)
示例9: test_it
def test_it(self):
from pyramid.interfaces import IRendererFactory
from pyramid_jinja2 import includeme
from pyramid_jinja2 import Jinja2RendererFactory
config = testing.setUp()
config.registry.settings['jinja2.directories'] = '/foobar'
includeme(config)
utility = config.registry.getUtility(IRendererFactory, name='.jinja2')
self.assertTrue(isinstance(utility, Jinja2RendererFactory))
示例10: test_bccache_instance
def test_bccache_instance(self):
from pyramid_jinja2 import includeme
import jinja2.bccache
mycache = jinja2.bccache.MemcachedBytecodeCache(DummyMemcachedClient())
config = testing.setUp()
config.registry.settings = {'jinja2.bytecode_caching': mycache}
includeme(config)
env = config.get_jinja2_environment()
self.assertTrue(env.bytecode_cache is mycache)
self.assertFalse(env.auto_reload)
示例11: test_default_bccache
def test_default_bccache(self):
from pyramid_jinja2 import includeme
import jinja2.bccache
config = testing.setUp()
config.registry.settings = {'jinja2.bytecode_caching': 'true'}
includeme(config)
env = config.get_jinja2_environment()
self.assertTrue(isinstance(env.bytecode_cache,
jinja2.bccache.FileSystemBytecodeCache))
self.assertTrue(env.bytecode_cache.directory)
self.assertFalse(env.auto_reload)
示例12: setUp
def setUp(self):
from pyramid_jinja2 import includeme
import jinja2.bccache
config = testing.setUp()
config.registry.settings = {}
includeme(config)
self.environment = config.get_jinja2_environment()
from pyramid_jinja2.filters import route_url_filter
self.environment.filters['route_url'] = route_url_filter
from pyramid.config import Configurator
self.config = Configurator(autocommit=True)
示例13: test_it
def test_it(self):
from pyramid_jinja2 import includeme
from pyramid_jinja2 import IJinja2Environment
import os
config = testing.setUp()
config.registry.settings['jinja2.directories'] = 'foobar'
includeme(config)
utility = config.registry.getUtility(IJinja2Environment)
self.assertEqual([x.split(os.sep)[-1]
for x in utility.loader.searchpath], ['foobar'])
config.add_jinja2_search_path('grrr')
self.assertEqual([x.split(os.sep)[-1]
for x in utility.loader.searchpath],
['foobar', 'grrr'])
示例14: test_it
def test_it(self):
import pyramid_jinja2.tests
from pyramid_jinja2 import includeme
import os
config = testing.setUp()
config.package = pyramid_jinja2.tests
config.registry.settings['jinja2.directories'] = 'foobar'
includeme(config)
env = config.get_jinja2_environment()
self.assertEqual(
[x.split(os.sep)[-3:] for x in env.loader.searchpath],
[['pyramid_jinja2', 'tests', 'foobar']])
config.add_jinja2_search_path('grrr')
self.assertEqual(
[x.split(os.sep)[-3:] for x in env.loader.searchpath],
[['pyramid_jinja2', 'tests', 'foobar'], ['pyramid_jinja2', 'tests', 'grrr']])
示例15: test_it_relative
def test_it_relative(self):
from pyramid.config import Configurator
from pyramid_jinja2 import includeme
from webtest import TestApp
def myview(request):
return {}
config = Configurator(settings={'jinja2.directories': 'templates'})
includeme(config)
config.add_view(view=myview, name='baz1',
renderer='baz1/mytemplate.jinja2')
config.add_view(view=myview, name='baz2',
renderer='baz2/mytemplate.jinja2')
app1 = config.make_wsgi_app()
testapp = TestApp(app1)
self.assertEqual(testapp.get('/baz1').body, bytes_('baz1\nbaz1 body'))
self.assertEqual(testapp.get('/baz2').body, bytes_('baz2\nbaz2 body'))