本文整理汇总了Python中wagtail.wagtailimages.formats.Format类的典型用法代码示例。如果您正苦于以下问题:Python Format类的具体用法?Python Format怎么用?Python Format使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Format类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestFormat
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)
示例2: setUp
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
示例3: setUp
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