summaryrefslogtreecommitdiff
path: root/tests/forms_tests/widget_tests/test_passwordinput.py
diff options
context:
space:
mode:
authorPreston Timmons <prestontimmons@gmail.com>2015-08-30 21:13:42 -0500
committerPreston Timmons <prestontimmons@gmail.com>2015-08-31 23:03:55 -0500
commit4c30fa905d9d47b3a2ee82095b1fe56cc2ec2ab5 (patch)
tree2bb04d4ecef539e4ebefbd6d750dfd240ddd7f0c /tests/forms_tests/widget_tests/test_passwordinput.py
parent5153a3bfdcec82324d67ff79862384288cf6afe6 (diff)
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.
Diffstat (limited to 'tests/forms_tests/widget_tests/test_passwordinput.py')
-rw-r--r--tests/forms_tests/widget_tests/test_passwordinput.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/forms_tests/widget_tests/test_passwordinput.py b/tests/forms_tests/widget_tests/test_passwordinput.py
new file mode 100644
index 0000000000..4cb7c4ef47
--- /dev/null
+++ b/tests/forms_tests/widget_tests/test_passwordinput.py
@@ -0,0 +1,26 @@
+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" />',
+ )