Simplified a ClearableFileInput test.
This commit is contained in:
parent
cb4be0262a
commit
55c3133df8
|
@ -1,6 +1,5 @@
|
||||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||||
from django.forms import ClearableFileInput
|
from django.forms import ClearableFileInput
|
||||||
from django.utils import six
|
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
|
|
||||||
from .base import WidgetTest
|
from .base import WidgetTest
|
||||||
|
@ -47,15 +46,15 @@ class ClearableFileInputTest(WidgetTest):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '''something<div onclick="alert('oops')">.jpg'''
|
return '''something<div onclick="alert('oops')">.jpg'''
|
||||||
|
|
||||||
widget = ClearableFileInput()
|
self.check_html(ClearableFileInput(), 'my<div>file', StrangeFieldFile(), html=(
|
||||||
field = StrangeFieldFile()
|
"""
|
||||||
output = widget.render('my<div>file', field)
|
Currently: <a href="something?chapter=1&sect=2&copy=3&lang=en">
|
||||||
self.assertNotIn(field.url, output)
|
something<div onclick="alert('oops')">.jpg</a>
|
||||||
self.assertIn('href="something?chapter=1&sect=2&copy=3&lang=en"', output)
|
<input type="checkbox" name="my<div>file-clear" id="my<div>file-clear_id" />
|
||||||
self.assertNotIn(six.text_type(field), output)
|
<label for="my<div>file-clear_id">Clear</label><br />
|
||||||
self.assertIn('something<div onclick="alert('oops')">.jpg', output)
|
Change: <input type="file" name="my<div>file" />
|
||||||
self.assertIn('my<div>file', output)
|
"""
|
||||||
self.assertNotIn('my<div>file', output)
|
))
|
||||||
|
|
||||||
def test_clear_input_renders_only_if_not_required(self):
|
def test_clear_input_renders_only_if_not_required(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue