test_templates.py 文件源码

python
阅读 41 收藏 0 点赞 0 评论 0

项目:DjangoCMS 作者: farhan711 项目源码 文件源码
def test_custom_templates(self):
        """
        Test that using CMS_TEMPLATES_DIR both template list and template labels are extracted from the new directory
        """
        config_path = os.path.join(settings.CMS_TEMPLATES_DIR, '__init__.py')
        with open(config_path, 'r') as openfile:
            mod = load_module("mod", openfile, config_path, ('m', 'r', PY_SOURCE))
        original_labels = [force_text(_(template[1])) for template in mod.TEMPLATES.items()]
        original_files = [os.path.join(PATH_PREFIX, template[0].strip()) for template in mod.TEMPLATES.items()]
        templates = get_cms_setting('TEMPLATES')
        self.assertEqual(len(templates), 3)
        labels = [force_text(template[1]) for template in templates]
        files = [template[0] for template in templates]
        if get_cms_setting('TEMPLATE_INHERITANCE'):
            original_labels.append(force_text(_('Inherit the template of the nearest ancestor')))
            original_files.append(constants.TEMPLATE_INHERITANCE_MAGIC)
        self.assertEqual(set(labels), set(original_labels))
        self.assertEqual(set(files), set(original_files))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号