2015-08-31 10:13:42 +08:00
|
|
|
from django.forms import PasswordInput
|
|
|
|
|
|
|
|
from .base import WidgetTest
|
|
|
|
|
|
|
|
|
|
|
|
class PasswordInputTest(WidgetTest):
|
|
|
|
widget = PasswordInput()
|
|
|
|
|
|
|
|
def test_render(self):
|
2018-01-21 15:09:10 +08:00
|
|
|
self.check_html(
|
|
|
|
self.widget, "password", "", html='<input type="password" name="password">'
|
|
|
|
)
|
2015-08-31 10:13:42 +08:00
|
|
|
|
|
|
|
def test_render_ignore_value(self):
|
2018-01-21 15:09:10 +08:00
|
|
|
self.check_html(
|
|
|
|
self.widget,
|
|
|
|
"password",
|
|
|
|
"secret",
|
|
|
|
html='<input type="password" name="password">',
|
|
|
|
)
|
2015-08-31 10:13:42 +08:00
|
|
|
|
|
|
|
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">'
|
2022-02-04 03:24:19 +08:00
|
|
|
)
|
2015-08-31 10:13:42 +08:00
|
|
|
self.check_html(
|
2018-01-21 15:09:10 +08:00
|
|
|
widget, "password", None, html='<input type="password" name="password">'
|
2022-02-04 03:24:19 +08:00
|
|
|
)
|
2015-08-31 10:13:42 +08:00
|
|
|
self.check_html(
|
2022-02-04 03:24:19 +08:00
|
|
|
widget,
|
2018-01-21 15:09:10 +08:00
|
|
|
"password",
|
2015-08-31 10:13:42 +08:00
|
|
|
"test@example.com",
|
2018-01-21 15:09:10 +08:00
|
|
|
html='<input type="password" name="password" value="test@example.com">',
|
2015-08-31 10:13:42 +08:00
|
|
|
)
|