本文整理汇总了Python中wagtail.wagtailimages.formats.Format.image_to_editor_html方法的典型用法代码示例。如果您正苦于以下问题:Python Format.image_to_editor_html方法的具体用法?Python Format.image_to_editor_html怎么用?Python Format.image_to_editor_html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wagtail.wagtailimages.formats.Format
的用法示例。
在下文中一共展示了Format.image_to_editor_html方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestFormat
# 需要导入模块: from wagtail.wagtailimages.formats import Format [as 别名]
# 或者: from wagtail.wagtailimages.formats.Format import image_to_editor_html [as 别名]
class TestFormat(TestCase):
def setUp(self):
# test format
self.format = Format("test name", "test label", "test classnames", "test filter spec")
# test image
self.image = MagicMock()
self.image.id = 0
def test_editor_attributes(self):
result = self.format.editor_attributes(self.image, "test alt text")
self.assertEqual(result, 'data-embedtype="image" data-id="0" data-format="test name" data-alt="test alt text" ')
def test_image_to_editor_html(self):
result = self.format.image_to_editor_html(self.image, "test alt text")
six.assertRegex(
self,
result,
'<img data-embedtype="image" data-id="0" data-format="test name" data-alt="test alt text" class="test classnames" src="[^"]+" width="1" height="1" alt="test alt text">',
)
def test_image_to_html_no_classnames(self):
self.format.classnames = None
result = self.format.image_to_html(self.image, "test alt text")
six.assertRegex(self, result, '<img src="[^"]+" width="1" height="1" alt="test alt text">')
self.format.classnames = "test classnames"
def test_get_image_format(self):
register_image_format(self.format)
result = get_image_format("test name")
self.assertEqual(result, self.format)