from django.forms import CharField, Form, PasswordInput from .base import WidgetTest class PasswordInputTest(WidgetTest): widget = PasswordInput() def test_render(self): self.check_html( self.widget, "password", "", html='' ) def test_render_ignore_value(self): self.check_html( self.widget, "password", "secret", html='', ) def test_render_value_true(self): """ The render_value argument lets you specify whether the widget should render its value. For security reasons, this is off by default. """ widget = PasswordInput(render_value=True) self.check_html( widget, "password", "", html='' ) self.check_html( widget, "password", None, html='' ) self.check_html( widget, "password", "test@example.com", 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( '
' '
', form.render(), )