本文整理汇总了Python中django.forms.ClearableFileInput.get_conditions方法的典型用法代码示例。如果您正苦于以下问题:Python ClearableFileInput.get_conditions方法的具体用法?Python ClearableFileInput.get_conditions怎么用?Python ClearableFileInput.get_conditions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.forms.ClearableFileInput
的用法示例。
在下文中一共展示了ClearableFileInput.get_conditions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_accept
# 需要导入模块: from django.forms import ClearableFileInput [as 别名]
# 或者: from django.forms.ClearableFileInput import get_conditions [as 别名]
def test_accept(self):
widget = ClearableFileInput()
assert 'accept' not in widget.render(name='file', value='test.jpg')
assert ["starts-with", "$Content-Type", ""] in widget.get_conditions(None)
widget = ClearableFileInput(attrs={'accept': 'image/*'})
assert 'accept="image/*"' in widget.render(name='file', value='test.jpg')
assert ["starts-with", "$Content-Type", "image/"] in widget.get_conditions('image/*')
widget = ClearableFileInput(attrs={'accept': 'image/jpeg'})
assert 'accept="image/jpeg"' in widget.render(name='file', value='test.jpg')
assert {"Content-Type": 'image/jpeg'} in widget.get_conditions('image/jpeg')
widget = ClearableFileInput(attrs={'accept': 'application/pdf,image/*'})
assert 'accept="application/pdf,image/*"' in widget.render(name='file', value='test.jpg')
assert ["starts-with", "$Content-Type", ""] in widget.get_conditions(
'application/pdf,image/*')
assert {"Content-Type": 'application/pdf'} not in widget.get_conditions(
'application/pdf,image/*')