def test_custom_file_widget(self): """ ``ClearableFileInput`` respects its ``file_widget`` argument. """ widget = ClearableFileInput(file_widget=ImageWidget()) html = widget.render('fieldname', ImageFieldFile(None, ImageField(), 'tiny.png')) self.assertTrue('<img' in html)
def test_custom_file_widget(self): """ ``ClearableFileInput`` respects its ``file_widget`` argument. """ widget = ClearableFileInput(file_widget=ImageWidget()) html = widget.render('fieldname', ImageFieldFile(None, ImageField(), 'tiny.png')) self.assertTrue(html.startswith( '<input type="file" name="fieldname_0" value="tiny.png" />' '<br /><img src="/media/tiny'))
def test_custom_template(self): """ ``ClearableFileInput`` respects its ``template`` argument. """ widget = ClearableFileInput(template='Clear: %(checkbox)s %(input)s') html = widget.render('fieldname', ImageFieldFile(None, ImageField(), 'tiny.png')) self.assertEqual(html, 'Clear: ' '<input type="checkbox" name="fieldname_1" /> ' '<input type="file" name="fieldname_0" />')
def test_custom_template(self): """ ``ClearableFileInput`` respects its ``template`` argument. """ widget = ClearableFileInput(template='Clear: %(checkbox)s %(input)s') html = widget.render('fieldname', ImageFieldFile(None, ImageField(), 'tiny.png')) self.assertHTMLEqual( html, 'Clear: ' '<input type="checkbox" name="fieldname_1" /> ' '<input type="file" name="fieldname_0" />')
def test_render(self): """ ``ClearableFileInput`` renders the file input and an unchecked clear checkbox. """ widget = ClearableFileInput() html = widget.render('fieldname', 'tiny.png') self.assertHTMLEqual( html, '<input type="file" name="fieldname_0" />' ' Clear: ' '<input type="checkbox" name="fieldname_1" />')
def test_render(self): """ ``ClearableFileInput`` renders the file input and an unchecked clear checkbox. """ widget = ClearableFileInput() html = widget.render('fieldname', 'tiny.png') self.assertEqual(html, '<input type="file" name="fieldname_0" />' ' Clear: ' '<input type="checkbox" name="fieldname_1" />')