diff options
| author | Arthur Vuillard <arthur.vuillard@gmail.com> | 2013-02-21 15:35:30 +0100 |
|---|---|---|
| committer | Arthur Vuillard <arthur.vuillard@gmail.com> | 2013-02-21 15:35:30 +0100 |
| commit | 7986de0a27488e489eae8ec47319dc6672fd8bdb (patch) | |
| tree | aebbcf74905a631a16e5eb5c3316ed12c9ee0394 /tests | |
| parent | 8fb0a2bea6a59a203d39793ee75bc1ef9b40cc41 (diff) | |
| download | webtest-7986de0a27488e489eae8ec47319dc6672fd8bdb.tar.gz | |
Little cleaning in test_forms.py
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_forms.py | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/tests/test_forms.py b/tests/test_forms.py index b40c64b..287d8c7 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -5,18 +5,25 @@ from tests.compat import unittest import webtest from webtest.forms import NoValue -class TestForms(unittest.TestCase): - def test_set_submit_field(self): - form = webtest.Form(None, ''' +PAGE_CONTENT = ''' <html> <head><title>Page without form</title></head> <body> <form method="POST" id="second_form"> + <select name="select"> + <option value="value1">Value 1</option> + <option value="value2" selected>Value 2</option> + <option value="value3">Value 3</option> + </select> <input type="submit" name="submit" /> </form> </body> </html> -''') +''' + +class TestForms(unittest.TestCase): + def test_set_submit_field(self): + form = webtest.Form(None, PAGE_CONTENT) self.assertRaises( AttributeError, form['submit'].value__set, @@ -24,25 +31,10 @@ class TestForms(unittest.TestCase): ) def test_force_select(self): - form = webtest.Form(None, ''' -<html> - <head><title>Page without form</title></head> - <body> - <form method="POST" id="second_form"> - <select name="select"> - <option value="value1">Value 1</option> - <option value="value2" selected>Value 2</option> - <option value="value3">Value 3</option> - </select> - </form> - </body> -</html> -''') + form = webtest.Form(None, PAGE_CONTENT) form['select'].force_value('notavalue') form['select'].value__set('value3') assert form['select']._forced_value is NoValue assert form['select'].value == 'value3' assert form['select'].selectedIndex == 2 - - |
