summaryrefslogtreecommitdiff
path: root/tests/forms_tests
diff options
context:
space:
mode:
authorRoman Selivanov <seroy@bk.ru>2017-07-19 18:24:27 +0300
committerTim Graham <timograham@gmail.com>2017-07-19 14:45:59 -0400
commit99d5059d766a18f80bb24a44023f9e653a08c803 (patch)
tree9460e3bb57ff7963c1154d35260873a54c764652 /tests/forms_tests
parenta5e91ab1fbf6badab51e04dd445d234bc11ddd0a (diff)
[1.11.x] Fixed #28414 -- Fixed ClearableFileInput rendering as a subwidget of MultiWidget.
Backport of d4da39685b5974849c73e4c4dc6e07dfdf21c67a from master
Diffstat (limited to 'tests/forms_tests')
-rw-r--r--tests/forms_tests/widget_tests/test_clearablefileinput.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/forms_tests/widget_tests/test_clearablefileinput.py b/tests/forms_tests/widget_tests/test_clearablefileinput.py
index 1e52f0f62e..8a075569c0 100644
--- a/tests/forms_tests/widget_tests/test_clearablefileinput.py
+++ b/tests/forms_tests/widget_tests/test_clearablefileinput.py
@@ -1,5 +1,5 @@
from django.core.files.uploadedfile import SimpleUploadedFile
-from django.forms import ClearableFileInput
+from django.forms import ClearableFileInput, MultiWidget
from django.utils.encoding import python_2_unicode_compatible
from .base import WidgetTest
@@ -77,6 +77,18 @@ class ClearableFileInputTest(WidgetTest):
"""
self.check_html(self.widget, 'myfile', None, html='<input type="file" name="myfile" />')
+ def test_render_as_subwidget(self):
+ """A ClearableFileInput as a subwidget of MultiWidget."""
+ widget = MultiWidget(widgets=(self.widget,))
+ self.check_html(widget, 'myfile', [FakeFieldFile()], html=(
+ """
+ Currently: <a href="something">something</a>
+ <input type="checkbox" name="myfile_0-clear" id="myfile_0-clear_id" />
+ <label for="myfile_0-clear_id">Clear</label><br />
+ Change: <input type="file" name="myfile_0" />
+ """
+ ))
+
def test_clear_input_checked_returns_false(self):
"""
ClearableFileInput.value_from_datadict returns False if the clear