From 4c30fa905d9d47b3a2ee82095b1fe56cc2ec2ab5 Mon Sep 17 00:00:00 2001 From: Preston Timmons Date: Sun, 30 Aug 2015 21:13:42 -0500 Subject: 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. --- .../forms_tests/widget_tests/test_passwordinput.py | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/forms_tests/widget_tests/test_passwordinput.py (limited to 'tests/forms_tests/widget_tests/test_passwordinput.py') 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='') + + 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='', + ) -- cgit v1.3