summaryrefslogtreecommitdiff
path: root/tests/forms_tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-05-14 10:31:32 -0400
committerTim Graham <timograham@gmail.com>2016-05-14 10:31:32 -0400
commit55c3133df86447129d5c912102f3c4f7b56092c6 (patch)
treed94634fb5ffa47fbf6d3f02fa8bd3e2dfecbbbed /tests/forms_tests
parentcb4be0262a491b4d13b2f9defe28940d31b2200e (diff)
downloaddjango-55c3133df86447129d5c912102f3c4f7b56092c6.tar.gz
Simplified a ClearableFileInput test.
Diffstat (limited to 'tests/forms_tests')
-rw-r--r--tests/forms_tests/widget_tests/test_clearablefileinput.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/tests/forms_tests/widget_tests/test_clearablefileinput.py b/tests/forms_tests/widget_tests/test_clearablefileinput.py
index 5c093dbd46..46bad58f3a 100644
--- a/tests/forms_tests/widget_tests/test_clearablefileinput.py
+++ b/tests/forms_tests/widget_tests/test_clearablefileinput.py
@@ -1,6 +1,5 @@
from django.core.files.uploadedfile import SimpleUploadedFile
from django.forms import ClearableFileInput
-from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
from .base import WidgetTest
@@ -47,15 +46,15 @@ class ClearableFileInputTest(WidgetTest):
def __str__(self):
return '''something<div onclick="alert('oops')">.jpg'''
- widget = ClearableFileInput()
- field = StrangeFieldFile()
- output = widget.render('my<div>file', field)
- self.assertNotIn(field.url, output)
- self.assertIn('href="something?chapter=1&amp;sect=2&amp;copy=3&amp;lang=en"', output)
- self.assertNotIn(six.text_type(field), output)
- self.assertIn('something&lt;div onclick=&quot;alert(&#39;oops&#39;)&quot;&gt;.jpg', output)
- self.assertIn('my&lt;div&gt;file', output)
- self.assertNotIn('my<div>file', output)
+ self.check_html(ClearableFileInput(), 'my<div>file', StrangeFieldFile(), html=(
+ """
+ Currently: <a href="something?chapter=1&amp;sect=2&amp;copy=3&amp;lang=en">
+ something&lt;div onclick=&quot;alert(&#39;oops&#39;)&quot;&gt;.jpg</a>
+ <input type="checkbox" name="my&lt;div&gt;file-clear" id="my&lt;div&gt;file-clear_id" />
+ <label for="my&lt;div&gt;file-clear_id">Clear</label><br />
+ Change: <input type="file" name="my&lt;div&gt;file" />
+ """
+ ))
def test_clear_input_renders_only_if_not_required(self):
"""