本文整理匯總了Python中django.template.library.InvalidTemplateLibrary方法的典型用法代碼示例。如果您正苦於以下問題:Python library.InvalidTemplateLibrary方法的具體用法?Python library.InvalidTemplateLibrary怎麽用?Python library.InvalidTemplateLibrary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.template.library
的用法示例。
在下文中一共展示了library.InvalidTemplateLibrary方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_package_libraries
# 需要導入模塊: from django.template import library [as 別名]
# 或者: from django.template.library import InvalidTemplateLibrary [as 別名]
def get_package_libraries(pkg):
"""
Recursively yield template tag libraries defined in submodules of a
package.
"""
for entry in walk_packages(pkg.__path__, pkg.__name__ + '.'):
try:
module = import_module(entry[1])
except ImportError as e:
raise InvalidTemplateLibrary(
"Invalid template library specified. ImportError raised when "
"trying to load '%s': %s" % (entry[1], e)
)
if hasattr(module, 'register'):
yield entry[1]
示例2: test_load_error
# 需要導入模塊: from django.template import library [as 別名]
# 或者: from django.template.library import InvalidTemplateLibrary [as 別名]
def test_load_error(self):
msg = (
"Invalid template library specified. ImportError raised when "
"trying to load 'template_tests.broken_tag': cannot import name "
"'Xtemplate'"
)
with self.assertRaisesMessage(InvalidTemplateLibrary, msg):
Engine(libraries={'broken_tag': 'template_tests.broken_tag'})
示例3: test_load_error_egg
# 需要導入模塊: from django.template import library [as 別名]
# 或者: from django.template.library import InvalidTemplateLibrary [as 別名]
def test_load_error_egg(self):
egg_name = '%s/tagsegg.egg' % self.egg_dir
msg = (
"Invalid template library specified. ImportError raised when "
"trying to load 'tagsegg.templatetags.broken_egg': cannot "
"import name 'Xtemplate'"
)
with extend_sys_path(egg_name):
with self.assertRaisesMessage(InvalidTemplateLibrary, msg):
Engine(libraries={'broken_egg': 'tagsegg.templatetags.broken_egg'})