Exemple #1
0
    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)
Exemple #2
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" />')
Exemple #3
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" />')