django/tests/forms_tests/widget_tests/test_passwordinput.py
Preston Timmons 4c30fa905d Rewrote form widget tests as proper unittests.
This is preparation for landing the template-based widget rendering
patch and goes a long way to making these tests more useful for future
development. The old doctest heritage is strong here.
2015-08-31 23:03:55 -05:00

27 lines
1.0 KiB
Python

from django.forms import PasswordInput
from .base import WidgetTest
class PasswordInputTest(WidgetTest):
widget = PasswordInput()
def test_render(self):
self.check_html(self.widget, 'password', '', html='<input type="password" name="password" />')
def test_render_ignore_value(self):
self.check_html(self.widget, 'password', 'secret', html='<input type="password" name="password" />')
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='<input type="password" name="password" />')
self.check_html(widget, 'password', None, html='<input type="password" name="password" />')
self.check_html(
widget, 'password', 'test@example.com',
html='<input type="password" name="password" value="test@example.com" />',
)