from django.forms import CharField, Form, Textarea from django.utils.safestring import mark_safe from .base import WidgetTest class TextareaTest(WidgetTest): widget = Textarea() def test_render(self): self.check_html( self.widget, "msg", "value", html=(''), ) def test_render_required(self): widget = Textarea() widget.is_required = True self.check_html( widget, "msg", "value", html='', ) def test_render_empty(self): self.check_html( self.widget, "msg", "", html='', ) def test_render_none(self): self.check_html( self.widget, "msg", None, html='', ) def test_escaping(self): self.check_html( self.widget, "msg", 'some "quoted" & ampersanded value', html=( '" ), ) def test_mark_safe(self): self.check_html( self.widget, "msg", mark_safe("pre "quoted" value"), html=( '" ), ) def test_fieldset(self): class TestForm(Form): template_name = "forms_tests/use_fieldset.html" field = CharField(widget=self.widget) form = TestForm() self.assertIs(self.widget.use_fieldset, False) self.assertHTMLEqual( '