summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDiarmuid Bourke <diarmuidbourke@gmail.com>2013-02-26 16:14:33 +0000
committerDiarmuid Bourke <diarmuidbourke@gmail.com>2013-02-26 16:14:33 +0000
commit4e0a736f6f96aa8a1d07b696b4a2cbf013db6e05 (patch)
treefc90e5167fe0fb0b340040b2cbec7ad939f38a0b /tests
parentdfff9b5ef6f480dcf832d9154af24b52707e3387 (diff)
downloadwebtest-4e0a736f6f96aa8a1d07b696b4a2cbf013db6e05.tar.gz
Tests for input fields of type password.
This checks that input fields with type password work and act like text input fields.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_forms.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_forms.py b/tests/test_forms.py
index 544690d..85c1db7 100644
--- a/tests/test_forms.py
+++ b/tests/test_forms.py
@@ -173,6 +173,10 @@ def input_app(environ, start_response):
<input name="foo" type="checkbox" value="bar" checked>
<input name="button" type="submit" value="text">
</form>
+ <form method="POST" id="password_input_form">
+ <input name="foo" type="password" value="bar">
+ <input name="button" type="submit" value="text">
+ </form>
<form method="POST" id="textarea_input_form">
<textarea name="textarea">&#39;&#x66;&#x6f;&#x6f;&amp;&#x62;&#x61;&#x72;&#39;</textarea>
</form>
@@ -207,6 +211,10 @@ def input_app_without_default(environ, start_response):
<input name="foo" type="checkbox" value="bar">
<input name="button" type="submit" value="text">
</form>
+ <form method="POST" id="password_input_form">
+ <input name="foo" type="password">
+ <input name="button" type="submit" value="text">
+ </form>
</body>
</html>
""")
@@ -238,6 +246,10 @@ u("""
<input name="foo" type="checkbox" value="Хармс" checked>
<input name="button" type="submit" value="Ура">
</form>
+ <form method="POST" id="password_input_form">
+ <input name="foo" type="password" value="Хармс">
+ <input name="button" type="submit" value="Ура">
+ </form>
</body>
</html>
""").encode('utf8')
@@ -269,6 +281,10 @@ class TestInput(unittest.TestCase):
self.assertEqual(form['foo'].value, 'bar')
self.assertEqual(form.submit_fields(), [('foo', 'bar')])
+ form = res.forms['password_input_form']
+ self.assertEqual(form['foo'].value, 'bar')
+ self.assertEqual(form.submit_fields(), [('foo', 'bar')])
+
def test_input_unicode(self):
app = webtest.TestApp(input_unicode_app)
res = app.get('/')
@@ -288,6 +304,10 @@ class TestInput(unittest.TestCase):
self.assertEqual(form['foo'].value, u('Хармс'))
self.assertEqual(form.submit_fields(), [('foo', u('Хармс'))])
+ form = res.forms['password_input_form']
+ self.assertEqual(form['foo'].value, u('Хармс'))
+ self.assertEqual(form.submit_fields(), [('foo', u('Хармс'))])
+
def test_input_no_default(self):
app = webtest.TestApp(input_app_without_default)
res = app.get('/')
@@ -307,6 +327,10 @@ class TestInput(unittest.TestCase):
self.assertTrue(form['foo'].value is None)
self.assertEqual(form.submit_fields(), [])
+ form = res.forms['password_input_form']
+ self.assertEqual(form['foo'].value, '')
+ self.assertEqual(form.submit_fields(), [('foo', '')])
+
def test_textarea_entities(self):
app = webtest.TestApp(input_app)
res = app.get('/')